Professional Documents
Culture Documents
Docf
Docf
The select statement is the basis for most SQL queries. If you want to get some data out
of the database to display it or use it for some other purpose, you're probably going to use a
select statement. The insert statement is used to add data to a table. Another statement is “update
statement” which is used to change the values of existing rows in a table. Addition to that this
week we will learn “delete statement” which is used to remove rows from the table.
For the SELECT statement/commend we need to use “SELECT” keyword. The syntax
FROM table_name;
If you need to select all, you need to use * sign. So syntax should be: SELECT * FROM
table_name; The asterisk means that all of the columns will be returned in this query. Some
database systems require a semicolon at the end of each SQL statement. Semicolon is the
standard way to separate each SQL statement in database systems that allow more than one SQL
The ORDER BY keyword sorts the records in ascending order by default. To sort the
records in a descending order, you can use the DESC keyword. The syntax should be like the
following:
FROM table_name
ORDER BY column_name;
1
SQL Count Function returns the number of rows that matches specified criteria. Syntax
should be :
SELECT column_name AS title, column_name AS title (use AS for how you would like to
name the column)
FROM table_name
ORDER BY column_name
LIMIT number;
For inserting data , we use “INSERT INTO” statement which is used to insert new
records in a table. Syntax:
For updating data, we use “UPDATE” statement which is used to update existing records
in a table.
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
For deleting data, we use “DELETE” statement which is used to delete rows in a table.