Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT Query without FROM clause with WHERE clause

Status
Not open for further replies.

jjames

Programmer
Mar 13, 2001
212
I am having a problem with the following Update query

INSERT INTO MyTable (Field1, Field2, Field3)
VALUES('Data1', 'Data2','Data3')
WHERE 'Data1' NOT IN (SELECT Field1 FROM MyTable)

It seems to expect a FROM clause but the data I want to insert does not come from a table, query, etc.
 
VALUES contains a list of values

you have to hardcode them

if you don't want to include a value that exists in another query, then don't -- include it, i mean

you have to do this, i.e. not include it, yourself, when you prepare the list of values -- remember, they are hardcoded literal values

does that make sense?

if you do hardcode a value, it will get inserted

are you perhaps pulling data1, data2, data3 from some other place?

in that case, you don't want INSERT...VALUES syntax, you want INSERT...SELECT syntax


rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top