Question

In MySQL, you can use the keyword USING in a join when you join on columns from different tables with the same name. For example, these queries yield the same result:

SELECT * FROM user INNER JOIN perm USING (uid)
SELECT * FROM user INNER JOIN perm ON user.uid = perm.uid

Is there an equivalent shortcut in SQL Server?

Was it helpful?

Solution

nope, have to use:

SELECT * FROM user INNER JOIN perm ON user.uid = perm.uid

OTHER TIPS

No, SQL Server does not support this kind of shortcut.

I would like to point out that even if it did, shortcuts like these are NOT A GOOD IDEA. I recently worked on a database where the developers thought it would be a good idea to use the *= and =* shortcuts for RIGHT JOIN and LEFT JOIN. Good idea until someone upgraded the SQL Compatibility level to 90. Then it became an extremely Bad Idea.

So, learn from us. Shortcuts are bad. A little extra typing never killed anyone.

Also, I would add not to use wild characters, "*" in your select statement - explicitly specify the column name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top