hi ,
I have four different tables, all are linked together using foreign key relationships.
Now i need to insert data in to the tables.How can i use nested insert queries to insert data by a single query?

hi ,
I have four different tables, all are linked together using foreign key relationships.
Now i need to insert data in to the tables.How can i use nested insert queries to insert data by a single query?

I suggest using transactions (you need the InnoDB storage engine for this).

start transaction
  insert into blah...
  insert into blah...
commit

If one of your statements causes an error none will be committed so you won't get corrupted data / missing keys etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.