• INSERT:
To insert values into a tableINSERT INTO TableName
VALUES(value1,value2,value3,value4)
Note: the values should match with the table rows and datatypes. To insert a NULL value, just keep the value blank between the commas.
Note: the values should match with the table rows and datatypes. To insert a NULL value, just keep the value blank between the commas.
• SELECT:
To select/display all contents of the Table
Using WHERE with Boolean operators for filtering the select/display
SELECT * FROM TableNameWHERE Column1=’12’ and Column2=’ddd’ or Column3=’ddsd’
Selecting a particular Column by using
SELECT Culumn1,Column2 from TableName
WHERE Column1=’’ AND Column2=’’
Counting the number of rows in a table
SELECT COUNT (*) FROM TableName
Filtering results by using LIKE
SELECT * FROM TableName
WHERE Column1 LIKE 'ABCD'
Filtering results for Column1 starting with ‘e’ and Column2 ending with ‘d’
SELECT * FROM TableName
WHERE Column1 LIKE ‘e%’ AND Column2 like ‘%d’
Filtering results for Column1 containing ‘a’ and Column2 containing any alphabet
SELECT * FROM TableName
WHERE Column1 LIKE ‘%e%’ AND Column2 like '[a-z]'
Note:
- similarly, ‘_d%’ mean d as second alphabet and so on.
- ‘ ‘-space or underscore represents the number of blanks that can be filled by anything and ‘%’ represents the remaining variable string.
- we can also use NOT LIKE for the opposite of LIKE.
No comments:
Post a Comment