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

Mutiple Where table in Update/Set

Status
Not open for further replies.

DeShaun

Technical User
Mar 3, 2017
16
0
0
US
I am writing the current update SQL

I am trying to update a field but the where requirements are from multiple table. I have tried a join and ON statement, but the error I receive is missing SET keyword

update SHRTCKG
set
SHRTCKG_CREDIT_HOURS = '1',
SHRTCKG_HOURS_ATTEMPTED = '1'
where
SHRTCKG_TERM_CODE = '201809'
and SFRSTCR_PIDM = SHRTCKG_PIDM
and SFRSTCR_CRN = '91643'
and SHRTCKG_CREDIT_HOURS = '0',
and SHRTCKG_HOURS_ATTEMPTED = '0';


 
If you run this:

[pre]
SELECT
SHRTCKG_CREDIT_HOURS ,
SHRTCKG_HOURS_ATTEMPTED
FROM SHRTCKG
where
SHRTCKG_TERM_CODE = '201809'
and SFRSTCR_PIDM = SHRTCKG_PIDM
and SFRSTCR_CRN = '91643'
and SHRTCKG_CREDIT_HOURS = '0',
and SHRTCKG_HOURS_ATTEMPTED = '0';
[/pre]
do you get the record(s) that you want to update?


---- Andy

There is a great need for a sarcasm font.
 

No. The from statement is missing a table SFRSTCR
 
If I have problems creating UPDATE statement, I try first to create SELECT statement that gives me the record(s) I want to Update.


---- Andy

There is a great need for a sarcasm font.
 
Also, I need to remove the comma and SHRTCKG_CREDIT_HOURS = '0'[highlight yellow],[/highlight]
 
Once I correct the statement, I am able to accurately select the fields I am updating.
 
That doesn't resolve the issue I am having with update SQL that I am writing.

The problem is since there is no from statement in my update syntax the script does not acknowledge the SFRSTCR table when running the update process. I am receiving an invalid identifier error for SFRSTCR_CRN.
 
Do you have a working SELECT statement retrieving correct record(s) to update?
If so, could you share it here?

Something like:[tt]
SELECT SHRTCKG_CREDIT_HOURS, SHRTCKG_HOURS_ATTEMPTED
FROM ...[/tt]


---- Andy

There is a great need for a sarcasm font.
 
SELECT
distinct SHRTCKG_CREDIT_HOURS , SHRTCKG_HOURS_ATTEMPTED, SHRTCKG_PIDM
FROM SHRTCKG,SHRTCKN
where
SHRTCKG_TERM_CODE = '201809'
and SHRTCKN_PIDM = SHRTCKG_PIDM
and SHRTCKN_CRN = '91643'
and SHRTCKG_CREDIT_HOURS = '1'
and SHRTCKG_HOURS_ATTEMPTED = '1';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top