Basic SQL syntax (another keywords that accompanies the SELECT command)
On the First tutorial Basic SQL Syntax i have write Generally keywords that accompanies the SELECT command. Here i write another keywords that we can use in SELECT command.
- LIMIT
This command is used to limit the results that returned from the SELECT command. - LIKE
This command is used to match the requested value from the database table.
Aggregate Functions :
- AVG()
This syntax is used to calculate the average amount of a particular column in a database. - COUNT()
This syntax use to count the number of records in a group of records. - MAX()
This syntax is used to find the greatest value in a particular column in a database. - MIN()
The opposite of MAX, this syntax is used to find the smallest value in a particular column in a database. - SUM()
This syntax is used to calculate the sum of all values that are in a field.
Here for the example :
SELECT * FROM your_table LIMIT 0, 10 //This will SHOW 10 row of your TABLE start FROM row 1 TO 10. SELECT * FROM your_table LIMIT 10, 10 //This will SHOW 10 row of your TABLE start FROM row 11 TO 20.
SELECT * FROM your_table WHERE your_column LIKE %'value'% //This will SHOW ALL row FROM your COLUMN that contain the value.
1 2 3 4 5 | SELECT AVG(your_column) FROM your_table SELECT COUNT(your_column) FROM your_table SELECT MAX(your_column) FROM your_table SELECT MIN(your_column) FROM your_table SELECT SUM(your_column) FROM your_table |
Categories: PHP, Javascript, Mysql, CSS Tags:
Basic SQL Syntax
SELECT
This command is used to obtain zero or more rows from one or more tables in the database. Generally keywords that accompanies the SELECT command is:
- FROM
Keyword to tell the origin table for which data is accessible also means table in combination. - WHERE
This keyword is used to determine which rows will be displayed based on the criteria listed in this clause. In the WHERE clause can use logical operators. - GROUP BY
This keyword is used to combine rows with related value. - HAVING
This keyword is used to find part of a combination of lines (line combinations generated when the query using the keywords GROUP BY or when the SELECT command contains aggregation) are produced. - ORDER BY
This keyword is used to determine the column used to sort the resulting data.
INSERT
This command is used to insert zero or more rows to the table.
UPDATE
This command is used to change the value of a set of rows in the table are available
DELETE
This command is used to remove zero or more existing rows from the table.
Example:
1 2 3 4 | SELECT * FROM myTable WHERE columnA = 'valueA' INSERT INTO myTable (columnA, columnB, columnC) VALUES (‘valueA’, ‘valueB’, ‘valueC’) UPDATE myTable SET columnA = ‘updateA’, columnB = ‘updateB’ WHERE columnC = ‘valueC’ DELETE FROM myTable WHERE columnA = ‘valueA’ |
Categories: PHP, Javascript, Mysql, CSS Tags: