Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

question about inner join syntax

I have been given this pseudo code in order to write my query. The pseudo code is from someone who is not really strong at SQL, however this persons hase a pretty good idea of what she wants.
So here is the pseudo code.
UPDATE Customer
SET Customer.Id = CopyCust.Id,
    Customer.IsCurrent = CopyCust.IsCurrent
   FROM Customer
   INNER JOIN CopyCust
  ON
Customer.Code = CopyCust.Code
Customer.SSN  = CopyCust.SSN
Customer.LastName = Customer.FirstName

I don't think you can join on several columns at one time. So, What I really think she wanst is the following solution: (What do you think Experts)

UPDATE Customer
SET Customer.Id = CopyCust.Id,
    Customer.IsCurrent = CopyCust.IsCurrent
FROM Customer
INNER JOIN CopyCust
ON
Customer.Code = CopyCust.Code
WHERE
Customer.SSN  = CopyCust.SSN
AND Customer.LastName = Customer.FirstName
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Brgdotnet, for small queries (and optionally for larger one), you can lose readability with aliases. They have their place, but for what you're doing, your original code was clean, easy to read and easy to advise on what to fine-tune.

I suggest you stay with your aesthetic and clean way of writing code, unless you decide for yourself to use abbreviations as aliases. They buy you nothing besides trading readability for keystrokes.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brgdotnet

ASKER

Thank you.
They buy you nothing besides trading readability for keystrokes.
We will have to agree to disagree.  In my view the version I posted is far more readable.
Igyftw.
I will have to take your word for it, as I have no idea what that means.