in Advanced 

Question preview

HomeQuestion preview:
Log in

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?
Do you know someone who could answer? Ask him for help
Answers: 1
Sort by: date rating
image 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!
If you haven't found what you've looking for, post a question
Ask question
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |