2 Replies - 5705 Views - Last Post: 02 May 2006 - 01:35 AM Rate Topic: -----

#1 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

inserting data into two tables

Posted 02 May 2006 - 01:10 AM

if i want to insert into two tables very similar data, the first table has an id which is the primary key and auto_increment, the second has id that is only primary key, but how do i set the second table's id, to be identical to the first table's autoincremented id ?
Is This A Good Question/Topic? 0
  • +

Replies To: inserting data into two tables

#2 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: inserting data into two tables

Posted 02 May 2006 - 01:19 AM

k i found it, thanks theRemix!

http://dev.mysql.com...-insert-id.html
if anyone is as noobish as me...
INSERT INTO tbl (auto,text) VALUES(NULL,'text');
INSERT INTO tbl2 (id,text) VALUES(LAST_INSERT_ID(),'text');

Was This Post Helpful? 0
  • +
  • -

#3 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: inserting data into two tables

Posted 02 May 2006 - 01:35 AM

is
$query1 = "DELETE FROM products WHERE id = '$id' AND cid = '$cid'";
$query2 = "DELETE FROM thumbsProducts WHERE id = '$id' AND cid = '$cid'";

the same as
$query1 = "DELETE FROM products,thumbsProducts WHERE id = '$id' AND cid = '$cid'";

?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1