Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server equivalent of MySQL's USING

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?

like image 823
Dinah Avatar asked May 13 '09 17:05

Dinah


People also ask

What is now () in SQL Server?

The NOW() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS.

What can I use instead of now in SQL?

DateTime2 is now the preferred method for storing the date and time in SQL Server 2008+.

What is SQL Server compile time parse?

Parse time is the time spent during checking SQL statement for syntax errors, breaking the command up into component parts, and producing an internal execution tree. Compile time is time spent during compiling an execution plan in cache memory from the execution tree that has just been produced.

Can SQL like be used for numbers?

The LIKE operator is used in the WHERE condition to filter data based on some specific pattern. It can be used with numbers, string, or date values. However, it is recommended to use the string values.


2 Answers

nope, have to use:

SELECT * FROM user INNER JOIN perm ON user.uid = perm.uid
like image 146
KM. Avatar answered Sep 30 '22 05:09

KM.


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.

like image 26
Sam Axe Avatar answered Sep 30 '22 06:09

Sam Axe