Jump to content

Insert query help


samoht

Recommended Posts

Hi,

 

I need a little help writting the correct code for inserting values into a mysql table after querying another.

 

From table tbl_posts I need to SELECT the ID WHERE guid LIKE %timalerts%

this returns a query of about 650 rows.

 

I then need to insert into table tbl_term_relationships an object_id that = the ID from the previous query and a term_id of 8 (in this case)

 

I know I'll need to do a loop - but I'm not sure which I should use? WHILE; FOREACH; ??

 

Please help,

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/176116-insert-query-help/
Share on other sites

Why don't you start by writing out some code (as best as possible) then we will have a better idea of what you are trying to do.  You might not need to do a loop as you can insert hundreds of items with a single insert statement.  I'll come back on here a bit later to check up and see what I can do to help out.

Link to comment
https://forums.phpfreaks.com/topic/176116-insert-query-help/#findComment-928005
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.