Subject: insert and/or update statement
Posted By: carswelljr Post Date: 9/28/2006 9:38:10 AM
I am having an issue with this SQL Statement i am trying to write. i want to insert the values (Test Facility) from CCID table INTO CCFD table where CCID.id = CCFD.id  this is what i have.

UPDATE CCFD.id
SET TEST_FACILITY = (SELECT CCID.id.TEST_FACILITY
FROM CCID.id
WHERE CCID.id = CCFD.id)

or

INSERT INTO CCFD.id
(Test_Facility)
SELECT TEST_FACILITY
FROM CCID.id
WHERE (CCFD.id.INDEX_ID = CCID.id.INDEX_ID)

thanks in advanced


Reply By: dparsons Reply Date: 9/28/2006 9:41:37 AM
What is the issue you are having??

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.
Reply By: carswelljr Reply Date: 9/28/2006 9:55:38 AM
the update statement is giving me an error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

and the insert statement error:

The multi-part identifier "Controlled_Checklist_Facility_Data.FAC_ID" could not be bound.



Reply By: dparsons Reply Date: 9/28/2006 10:03:36 AM
Ok first about your update statements, basically you can only use a subquery with

SET value = (sub query) if that sub query only returns one value.  

And I do not see where you are referencing a Column of FAC_ID in your INSERT statement?

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.

Go to topic 50365

Return to index page 162
Return to index page 161
Return to index page 160
Return to index page 159
Return to index page 158
Return to index page 157
Return to index page 156
Return to index page 155
Return to index page 154
Return to index page 153