Reference question and auto increment

2001-04-19 Thread Fates

I am trying to understand references in tables and using primary keys with
auto increment option as a reference to all tables:

What is the best way to reference other tables?  I have three tables:
menus, categories, and links.  I also have an ID field in each table that
uses the autoincrement option and is the primary key which is used to
reference the other tables.  This works great for referencing except when
a record is deleted. When a record is deleted and you add another record
the ID is not assigned the deleted records ID instead it skips the deleted
record ID and uses the next ID when you would expect it to use the deleted
ID which then causes problems with query to display all records from all
tables.  Maybe if I could use REPLACE to replace the deleted record that
might work.

I guess the solution is to create a new field common to all tables called
record_id and not use the auto increment option and enter the record ID
manually for each record I add.  The problem with this is I have to
remember what the previous record was if I want it to be in order. Is
there a better way to do this.  I like the auto increment option. 

I saw an example where three tables all contain a customerid which links
all the tables together.  Lets say I delete a customerid in one table but
not the others. Does the database automatically delete the other
cutomerids in the other tables that correspond to the customerid that was
deleted or is it up to the programmer to delete the other two id's.  




--
This email was sent using w3mail.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Output from select is not what expected

2001-04-18 Thread Fates

 I have three tables in a database called menus and I have added 2 records
to each table so 2*3=6 records.  Why is it when I do a "select * from
table1, table2, table3" I get 8 records back when there are only 2 records
in each table?  What am I doing wrong? Some of the fields are references
if that makes a difference?  I want to list the output from all tables
together.

Using Latest MySQL RedHat Linux RPM
--
This email was sent using w3mail.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Inserting data to multiple table at once

2001-04-18 Thread Fates

 How do I insert data into multiple tables without having to use multiple 

   insert statements? Can I just do Insert into table1 (data) table2
(data) 
   table3 (data) or do I have to use seperate INSERT statements for each
table? I would like to add all at once from web page form


 $query = "INSERT INTO $table VALUES ('$menu_id', '$server',
'$menunumber', '$menuname')";

--
This email was sent using w3mail.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php