In below sections there are basics sql queries about SELECT , WHERE , AND OR NOT , INSERT … There are other query commands also those we will see in the Next blog …
SELECT
Select command is use for to get the data from the table
Example: SELECT * FROM tablename
The above example will display all the columns from the table. If we want to display particular fields in the table then we have to use column-name operator.
If we want to display certain field without any duplicates then we use the DISTINCT keyword along with the select command.
WHERE
If we need only certain records from the table then we use the where clause. Where clause acts as a Filtering mechanism. Under the Where section we need to specify certain conditions, only if those conditions are met the records will be extracted.
Example: SELECT * FROM tablename WHERE columnname = value
AND, OR, NOT
If we need to add two or more conditions in the where clause then we can use the above-mentioned operators. These keywords will add more complexity to the query.
- AND Operator: This operator displays a record if all the conditions separated by AND are TRUE.
- OR Operator: This operator displays a record if any of the conditions separated by OR is TRUE.
- NOT Operator: This operator displays a record if the condition/conditions are NOT TRUE.
INSERT INTO
If we want to insert any new record or data into a table then we can use the INSERT query. We can use the Insert into in two ways:
Here we specify the column names for which we need to insert the record.
INSERT INTO table_name (column1, column2,…)VALUES (value1, value2, value3, …);