Link to home
Start Free TrialLog in
Avatar of Damian Gardner
Damian Gardner

asked on

Need help on a SQL Server 2008 inner join

Hello - I'm a little rusty on my SQL, and I have an inner join that I need to modify to add an extra table and field to it, and am getting syntax errors.  I'm attaching a text file with the SQL in it, which is the SQL from the design of an existing view in the database.  I basically need to join an additional table called CUSTPACKINGSLIPJOUR to the first table in the view (SALESDATA) on the "salesid" fields, so that I can also pull a field called "packingslipid" in the view. How do I do it so that it doesn't cause duplicate lines that are unnecarry in the view?

Thanks for your help
inner-join.txt
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
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
Avatar of Damian Gardner
Damian Gardner

ASKER

Ok - great.  Yes - I agree your method for the aliases is much more clear.  I'll try this on the database and see how it works, and let you know.

thank you!
BTW - the CUSTPACKINGSLIPJOUR table is in there twice, since I added the last piece onto the existing design.  Should I remove my piece of it?
Didn't see that.  In that case, remove the 'H' line from the FROM block, and in the bottom of the SELECT block change H.PACKINGSLIPID to G.PACKINGSLIPID.

The existing JOIN is SalesiD and dataaReaID, which is different from the SalesiD posted in your question, in case that matters.
I took my piece out, and it works like a charm.  thanks for your help. appreciate it.
No prob.  Thanks for the grade, good luck with your project.  -Jim