Hello,

I have two tables one for the customer_records and one for the jobs. Both tables are linked together(both contains customerID and foreign key is set)

I am trying to insert data into the job table by obtaining the customer ID that is given in the textbox.

I have:

    INSERT INTO jobs (priority, date, deadline, material, status) VALUES (?, ?,?,?,? ) select customerID from Customer where CustomerID =?"

But still get an error.

Can you guys give me a hint, that will be appreciated.

Regards.

PS: I am using java and mysql if this can help.

Try this version. It looks like you have got your WHERE condition syntax incorrect

INSERT INTO jobs (priority, date, deadline, material, status) VALUES (?, ?,?,?,? ) WHERE customerID = (SELECT customerID from Customer where CustomerID =?)

I changed it and got:
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 'WHERE customerID = (SELECT customerID from Customer where CustomerID ='3')'

You cannot INSERT with a WHERE condition. You can UPDATE or DELETE with a WHERE condition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.