Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2006, 09:38 AM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert and/or update statement

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


 
Old September 28th, 2006, 09:41 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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.
 
Old September 28th, 2006, 09:55 AM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.



 
Old September 28th, 2006, 10:03 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple columns in an update statement debbiecoates SQL Server 2000 1 August 17th, 2008 04:01 AM
T-SQL statement causing error with insert/update saf SQL Language 0 September 7th, 2007 04:48 PM
Insert Statement Iashia06 Access 0 April 7th, 2006 12:45 PM
Problems with my Insert Statement brendan82 Beginning VB 6 1 January 6th, 2004 08:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.