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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert error

Status
Not open for further replies.

masterchef

Programmer
Mar 26, 2007
18
0
0
GB
I am getting errors with a MySQL insert query which is puzzling me, it is based on the following query that works perfect.

INSERT INTO selected_product_parent_options (F_ID, NAME) (SELECT {GET.NxT_ID}, NAME FROM parent_options WHERE NAME NOT IN (SELECT NAME FROM selected_product_parent_options) OR {GET.NxT_ID} NOT IN (SELECT F_ID FROM selected_product_parent_options))

The problem is in this query

INSERT INTO selected_product_parent_options (F_ID, NAME, LK_ID) (SELECT {GET.NxT_ID}, NAME FROM parent_options WHERE NAME NOT IN (SELECT NAME FROM selected_product_parent_options) OR {GET.NxT_ID} NOT IN (SELECT F_ID FROM selected_product_parent_options), ID FROM parent_options WHERE ID NOT IN (SELECT LK_ID FROM selected_product_parent_options) OR {GET.NxT_ID} NOT IN (SELECT F_ID FROM selected_product_parent_options) OR NAME FROM parent_options WHERE NAME NOT IN (SELECT NAME FROM selected_product_parent_options) OR {GET.NxT_ID} NOT IN (SELECT F_ID FROM selected_product_parent_options))

Error:
SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ID FROM parent_options WHERE ID NOT IN (SELECT LK_ID FROM selec.

A Big thanks to CognosChicago for all his help with the first query.

Many Thanks to all in advance
IJS

 
Probably the best way to tackle this kind of problem is to start with your working INSERT statement and then gradually change it one step at a time and testing each change until you find the change that causes the error.


Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top