How to query one table and add rows to another using that first query? MySQL

Posted by Nickelbids on Stack Overflow See other posts from Stack Overflow or by Nickelbids
Published on 2010-03-11T19:55:19Z Indexed on 2010/03/11 19:59 UTC
Read the original article Hit count: 112

Filed under:
|
|

Hello,

I have some users setup in a MySQL table with different variables. I am trying to figure out what would be the best way to do this. Basically I want to award all of my registered and active users with bids which are stored in another table.

So for the Table "users" I have ran this query:

SELECT * FROM users WHERE active = 1 AND admin = 0 ORDER BY users.id ASC

Which will show all active users who are not administrators.

Now I would like to give each one of these users which are identified by the "ID" field in another table.

So in the "bids" table I would need to add a new row for each one of those users with all of the same values except for the "user_id" field which will basically match the "id" field of the table "users"

What would be the best approach for this. There are approximately 6,000+ users coming up in the first query.

Please be gentle as I am not a programmer. Just need some friendly advice.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php