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!

MySQL insert problem 1

Status
Not open for further replies.

masterchef

Programmer
Mar 26, 2007
18
0
0
GB
Hi All

This is my first posting so I hope I am in the correct area! The following code works perfect

INSERT INTO selected_product_parent_options (NAME) SELECT NAME from parent_options WHERE NAME NOT IN (SELECT NAME from selected_product_parent_options)

how ever if I try this
INSERT INTO selected_product_parent_options (F_ID, NAME) VALUES (2, SELECT NAME from parent_options WHERE NAME NOT IN (SELECT NAME from selected_product_parent_options))

I get errors, As you can see I am comparing two table columns and copying all the entry's in NAME form one table to another, this time around I also want to insert a value into F_ID. I have no idea what I am doing wrong, All and any help would be much appreciated.
 
Let me buy you a beer!! we final got there! works perfect, not to self( LEARN MORE MYSQL!!)

seriously thank you so much I can go home now!
 
No problem. I knew there was a solution out there somewhere. SQL can be confusing and tricky, but we figured it out. Go home!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top