Merge pull request 'Added CommonCommands.sql' (#1) from AddCommonCommands into master

Reviewed-on: https://linux.cgdesign.net/CGDesign/SQL_Scripts/pulls/1
This commit is contained in:
cglavan 2023-03-31 00:41:48 +00:00
commit b333058aeb

20
CommonCommands.sql Normal file
View File

@ -0,0 +1,20 @@
--Select all rows/columns from a TABLE
SELECT * FROM myTable
--Select top 10 rows from a TABLE
SELECT TOP(10) * FROM myTable
--Select specific columns from a TABLE
SELECT Id, FirstName, LastName FROM myTable
--Select all rows matching the last name Smith
SELECT * FROM myTable WHERE LastName = 'Smith'
--Select all rows in ascending/descending ORDER
SELECT * FROM myTable ORDER BY CreateDate --ascending
SELECT * FROM myTable ORDER BY CreateDate DESC --descending
--Select matching records from 2 tables
SELECT * FROM table1 t1
JOIN table2 t2 ON t1.Id = t2.Id