5

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?

1 Answer 1

7

Use:

INSERT INTO `subscrips` 
SELECT 37, id 
  FROM `proj_objects` 
 WHERE type = 'fthread'
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, worked Great for a query which was returning some ids, and I wanted to insert some rows in another table based on the former ids.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.