Explain how to sort data by providing examples for the following.
1. Sorting by Multiple Columns
2. Specifying sort directionSort data :
The ORDER BY clause in MySQL can be used to sort the specified column. Default sorting is ascending.Sorting by Multiple Columns
SELECT employee_id,salary FROM employee ORDER BY salarySpecifying sort direction
SELECT employee_id,salary FROM employee ORDER BY salary DESC;
State generic SQL syntax and an example of SELECT command along with LIKE clause to fetch data from MySQL table.
LIKE clause is used for pattern matching. % is used to match any string of any length where as _ allows you to match on a single character.Syntax:
SELECT * FROM table_nameExample:
WHERE column_name like 'pattern%';
SELECT * FROM employee
WHERE emp_name like 'ma%';