Insert multiple rows based on number of clients from another table
Posted on 2010-09-06
Using php and mysql,
I have a table called "certificates" and another table called "clients". I'd like to issue a certificate to every client in the database based on the existance of their user_id within the client table.
Basic logic being
Grab all unique user_ids from table clients
Insert into certificates the certificate value (from POST data) and a new row for every unique user_id
So the end result is if there are 10 user_ids in clients, 10 certificates will be issued... 1 for each client. I do store the user_id in the certificate table for obvious reasons.