[thelist] SQL: Insert with Sub Queries

Matt Warden mwarden at gmail.com
Tue Jun 20 09:33:17 CDT 2006


On 6/20/06, Casey Crookston <caseyc at intellisoftmn.com> wrote:
> What would be the correct way to build this query:
>
>
>
> INSERT INTO photos (vehicleID, photo, isMain, sortOrder) VALUES
> ((SELECT vehicleID FROM Vehicles), (SELECT vehicleimage FROM  Vehicles),
> 'Yes', 1)

Hard to tell. Maybe:

INSERT INTO photos (vehicleID, photo, isMain, sortOrder)
SELECT vehicleID, vehicleimage, 'Yes', 1
FROM Vehicles

This is of course if your db supports the insert... select syntax.
What db are you using?

-- 
Matt Warden
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list