MySQL Commands
MySQL Commands
16. We can filter records using WHERE clause. It returns only those records
which fulfill a specified set of condition.
SELECT column_list
FROM table_name
WHERE condition;
For example, if we want to write a query to retrieve the name of students
whose score is less than 80, it will look something like this:
SELECT Name from Marks
WHERE Marks <80;
17. Counting the number of rows in a table:
SELECT COUNT(*)
FROM table_name;
18. To add a new row to a table, do the following:
INSERT INTO table_name(column_list)
VALUES(value_list);
19. Update data for a set of rows defined by a WHERE clause criteria:
UPDATE table_name
SET column_1 = value_1,
…
WHERE condition;
20. To delete all rows in a table, the syntax is:
DELETE FROM table_name;
21. To delete rows specified by a condition:
DELETE FROM table_name
WHERE condition;