View Full Version : using select in an insert question
08-13-2007, 04:49 PM
is it possible to do an insert query with the values being select statements?
INSERT INTO table(val1, val2) VALUES("SELECT ...", val2);
or would I need to store the "insert value" to a variable first?
insert into table (col1, col2) values ((select x from sometable), val2);should give you no problems so long as the inner SELECT returns only one row.
08-17-2007, 04:58 PM
this is sort of similar to my initial question, as some of the fields I am retrieving will than be used later in the insert question I asked above
I want to grab the info for a part where the part is associated with the printer being displayed, and the client has access to that specific printer.
SELECT part_id, part_info FROM parts WHERE part_info LIKE %$searchTerms% AND
MATCH( SELECT printer_id FROM parts_printer WHERE parts.part_id = parts_printer.part_id )
for most parts, the printer_id will actually result in an array or printers, rather than a single printer... will the match clause check each printer in the partprinter array to the usersprinters ($this-printerArray) that is located in the session.
and also, if it does match one of printers, will it abort the search for that part? because I already know the part belongs to that printer, and if the user has access to the printer, there is no need to check if there the user has access to another printer in the range of possibilities
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.