Insert multiple rows into MySQL
I want to create a message to all users in my system and I want to see who has read it.
So I want to insert into existing table :
'Unread messages' with columns 'user_id' and 'message_id'
all user Ids from the 'User' table and one and the same message Id.
How can I do this in one statement?
xpert
13:26/28.03.2008
1.8 from possible 5 with 5 votes
Yes, you can insert like this:
insert into unread_messages(user_id, message_id)
(select id,12345 from users)
Where 12345 is the message_id that you received.
Vote:
Please vote! Your opinion matters!