×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Mutiple Where table in Update/Set

Mutiple Where table in Update/Set

Mutiple Where table in Update/Set

(OP)
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';


RE: Mutiple Where table in Update/Set

If you run this:

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';
 
do you get the record(s) that you want to update?


---- Andy

There is a great need for a sarcasm font.

RE: Mutiple Where table in Update/Set

(OP)

No. The from statement is missing a table SFRSTCR

RE: Mutiple Where table in Update/Set

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.

RE: Mutiple Where table in Update/Set

(OP)
Also, I need to remove the comma and SHRTCKG_CREDIT_HOURS = '0',

RE: Mutiple Where table in Update/Set

(OP)
Once I correct the statement, I am able to accurately select the fields I am updating.

RE: Mutiple Where table in Update/Set

thumbsup2


---- Andy

There is a great need for a sarcasm font.

RE: Mutiple Where table in Update/Set

(OP)
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.

RE: Mutiple Where table in Update/Set

Do you have a working SELECT statement retrieving correct record(s) to update?
If so, could you share it here?

Something like:
SELECT SHRTCKG_CREDIT_HOURS, SHRTCKG_HOURS_ATTEMPTED
FROM ...


---- Andy

There is a great need for a sarcasm font.

RE: Mutiple Where table in Update/Set

(OP)
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';

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close