Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from <table name> where <column name> = 'value' (equal)
- select * from <table name> where <column name> <> 'value' (not equal)
- ### OPERATORS AND WILD CARDS ###
- IN - Specify a List of values
- BETWEEN - Specify a Range
- LIKE - Specify a Pattern
- NOT - Not in a list, range, etc...
- % - Specifies zero or more characters
- _ - Specifies exactly one character
- [] - Any character within the brackets
- [^] - Not any character within the brackets
- select * from <table name> where Age = 20 or Age = 21 or Age = 24
- select * from <table name> where Age IN (20, 21, 24)
- select * from <table name> where Age BETWEEN 30 AND 35
- select * from <table name> where Email LIKE '_@_.com'
- select * from <table name> where Name LIKE '[MST]%' (selects all the names starting with M, S or T)
- ### ORDERING/SORTING THE RESULTS ###
- select * from <table name> ORDER BY Name
- By default, they are sorted in Ascending order. We can sort them in Descending:
- select * from <table name> ORDER BY Name DESC
- We can also sort by multiple columns:
- select * from <table name> ORDER BY Name DESC, Age ASC
- select top 10 * from <table name> (selecting the top 10 rows)
- select top 5 percent from <table name> (selecting the top 5%)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement