Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert into select from SQL query with both query and static values

I am trying to perform insert query from one specific column from a table plus two static values, I am trying something like this:

INSERT INTO TableA(PolicyId, Type, Used)
SELECT ID FROM Policies, 'A', 1 

But I am getting error near 'A' per SSMSE. How can I tackle this task?

like image 739
Laziale Avatar asked Oct 15 '25 04:10

Laziale


1 Answers

You'll need to put these static values in your SELECT clause:

INSERT INTO TableA(PolicyId, Type, Used) SELECT ID, 'A', 1 FROM Policies
like image 75
Mike Christensen Avatar answered Oct 17 '25 13:10

Mike Christensen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!