Skip to content Skip to sidebar Skip to footer

SQL Insert? Insert Data From One To Another

Firstly please understand that SQL is not one of my strong areas at the moment and i am a little unsure why i cannot get the query to-do this, it seems possible. we are running a m

Solution 1:

You're mixing up two different styles of INSERT.

To use the same method as your example, you'd need to do:

INSERT INTO filenote(clientid, notetype, datetime, notedetails)
SELECT clientid, 'info','2011-09-29 09:00:00', 'example note'
FROM clienttable
WHERE clienttable.clientid in (1,2,3,4,5,6,7,8,9)

or use BETWEEN:

INSERT INTO filenote(clientid, notetype, datetime, notedetails)
SELECT clientid, 'info','2011-09-29 09:00:00', 'example note'
FROM clienttable
WHERE clienttable.clientid BETWEEN 1 AND 9

Solution 2:

insert into filenote(clientid, notetype, datetime, notedetails)
select clienttable.clientid, 'info','2011-09-29 09:00:00', 'example note' from clienttable 
where clienttable.clientid between 1 and 9

Solution 3:

INSERT INTO filenote(clientid, notetype, datetime, notedetails)
SELECT clienttable.clientid, 'info','2011-09-29 09:00:00', 'example note'
FROM clienttable
WHERE clienttable.clientid in (1,2,3,4,5,6,7,8,9);

Post a Comment for "SQL Insert? Insert Data From One To Another"