Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL or short cuts?

Tags:

sql

SELECT * FROM nobel
WHERE winner = 'Theodore Roosevelt' or winner = 'Woodrow Wilson' or winner = 'Jed Bartlet' or winner = 'Jimmy Carter';

Is there a way to shorten this? Perhaps a way to use regex?

like image 457
Gates VVang Avatar asked Mar 22 '15 19:03

Gates VVang


People also ask

What does Alt F1 do in SQL Server?

ALT + F1 (Select any stored procedure on query editor and press ALT + F1) : It runs the sp_help system stored procedure. CTRL + 1: In the same way, it runs the sp_who system stored procedure. It will provide you the details like who created the SP, spid, host name, on which DB the SP was created and so on.

What does F9 do in SQL?

Execute (F9) only executes the statement you have selected. Execute as script (F5) executes every statement in the editor in order.


1 Answers

You want the in operator:

SELECT n.*
FROM nobel n
WHERE n.winner IN ('Theodore Roosevelt', 'Woodrow Wilson', 'Jed Bartlet', 'Jimmy Carter');
like image 187
Gordon Linoff Avatar answered Oct 24 '22 08:10

Gordon Linoff