views:

27

answers:

1

This query will return a list of project IDs that represent forum threads:

SELECT id FROM `proj_objects` WHERE  type='fthread';

This query will subscribe a user (whose ID in the users table is '37') to the forum thread with an ID of '122':

INSERT INTO `subscrips` VALUES ( 37, 122 ) ;

I'd like to insert multiple rows that will subscribe user 37 to all project objects where type is fthread. Can I do this in a single query?

+3  A: 

Use:

INSERT INTO `subscrips` 
SELECT 37, id 
  FROM `proj_objects` 
 WHERE type = 'fthread'
OMG Ponies
Cool! Thank you!