The answer to your IT questions
 

Advanced search  • Search tips
My QUESTIONS & ANSWERS
 Question:
Home » Database » MySQL :

Insert multiple rows into MySQL

User Asked by: milen
Published on: 11:26/28.03.2008
Status: OPEN
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?
 Answers: 1
Sort by: /\ date | rating
Image Answer by: xpert
Posted on: 11:26/28.03.2008
Rating: 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
  
| Home | Hall of fame | Register | Log in | Terms of service | Help | Contacts |