insert into select from other table
- by user3815079
I need to add multiple records based on data from another table where the event is the same.
I've found on this forum
insert into table2(id,name)
select "001",first_name from table1 where table1.id="001"
as possible solution for my question.
So I thought this should be the following syntax:
insert into reservations(event,seat) select "99",id from seats where seats.id>0
to add all seats to event 99.
However when I run this query mysql gives the message 'MySQL returned an empty resultset (0 rows). (query 0.0028 sec)' and no records were added. I translated the message so could be sligthly different.
When I only use the "select "99",id from seats where seats.id0" query, it returns me 1080 rows.