INSERT results of a SELECT statement and constants

T

Tim Zych

How insert into a table constants along with the results of a SELECT
statement?

This doesn't work

INSERT INTO tblCode ( CatID, Title, Code ) VALUES ((SELECT tblCats.CatID
FROM tblCats WHERE tblCats.Cat = "Category1") , 'Title1', 'Code1');
 
D

Duane Hookom

Try:
INSERT INTO tblCode (CatID, Title, Code)
SELECT CatID, "title1", "Code1"
FROM tblCats
WHERE Cat="Category1";
 
C

chris

Try...
INSERT INTO tblCode ( CatID, Title, Code ) SELECT
tblCats.CatID, 'Title1' as title, 'Code1' as code
FROM tblCats WHERE tblCats.Cat = "Category1";


-----Original Message-----
How insert into a table constants along with the results of a SELECT
statement?

This doesn't work

INSERT INTO tblCode ( CatID, Title, Code ) VALUES ((SELECT tblCats.CatID
FROM tblCats WHERE tblCats.Cat
= "Category1") , 'Title1', 'Code1');
 
Top