INSERT results of a SELECT statement and constants

  • Thread starter Thread starter Tim Zych
  • Start date Start date
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');
 
Try:
INSERT INTO tblCode (CatID, Title, Code)
SELECT CatID, "title1", "Code1"
FROM tblCats
WHERE Cat="Category1";
 
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');
 
Back
Top