Tag: MySql Order BY

Best way to order the best matching records in MySQL

If we are searching a word (string) in the mysql table, usually we will use the below method: [sql] SELECT * FROM user WHERE name LIKE ‘%searchstring%’ ORDER BY name ASC; [/sql] If you search like this, It will order the result set based on the ASC of name. It will not order the result …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/08/best-way-to-order-the-best-matching-records-in-mysql/

PHP MYSQL ORDER BY Multiple Columns

If you want to Order 2 or more columns in SQL Query. When ordering by more than one column, the second column is only used if the values are identical with the onces in the first column. Example [sql] ‘Order by Column ORDER BY COLUMN1, COLUMN2 [/sql] Order 2 or more columns with different orders …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/09/php-mysql-order-by-multiple-columns/