Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server Joins - 'Using' Keyword

Author  Topic 

arjun_duddu
Starting Member

3 Posts

Posted - 2011-12-31 : 11:45:47
Hello,

I am working with joins, i have worked with SQL rather than SQL Server, observed that in the SQL 'Using' keyword would help in customizing joins, which would make a query Simple.

I am unable to Customize the same query in SQL Server, Does SQL Server do not Support the 'Using' functionality? if it does how can i do it.


Could anyone provide me the HELP needed in this.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-31 : 11:57:01
Could you explain what this "using" does? I'm sure there's something similar in SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

arjun_duddu
Starting Member

3 Posts

Posted - 2011-12-31 : 12:10:31
Usage:
The USING clause lists those attributes common to both tables that must have the same value to be in the result.


Consider i have two tables
1.Ingredients
2.Vendors (Supplies the Ingredients)

My Requirement:i want to retrieve the names supplied by a specific vendor:

Sol :I can do this in following ways:

1.
select name,companyname
from ingredients i,vendors v
where i.vendorid = v.vendorid
and v.companyname = 'Spring Water Supply'


and Other Using 'Using'

2.
SELECT companyname, name, vendorid
FROM ingredients JOIN vendors v USING (vendorid)
WHERE v.companyname = 'Spring Water Supply';

Note:
Vendorid is common for both the tables

I am unable to work out with Second in SQL Server
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-31 : 14:27:11
Here you go:

SELECT v.companyname, name, i.vendorid
FROM ingredients i
JOIN vendors v
ON i.vendorid = v.vendorid
WHERE v.companyname = 'Spring Water Supply';

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-12-31 : 14:43:08
SQL Server doesn't have a USING clause nor does it have natural joins.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

arjun_duddu
Starting Member

3 Posts

Posted - 2012-01-01 : 02:11:40
ok, i was in a picture that, SqL Server Supports 'Using' keyword.

Thank you for the Information.
Go to Top of Page
   

- Advertisement -