New answers tagged order-by
This is quite a common problem! A case expression helps here. A query something like (untested) select * from table where name like '%ci%' order by case when name like 'ci%' then 0 else 1 end, name; should do what you want.
You should use ORDER BY CASE to sort the items in a way that suits your specific purpose. See here and here for examples on the usage. More CASE operator info here
The answer for this simple case is Yes. Rows are inserted in the provided order in the VALUES expression. But this is an implementation detail and there are no guarantees. In particular, the order is not necessarily maintained in more complex queries with WHERE conditions or joins. And there is no order in a database table. Physical order of rows may change ...
The correct query is: UPDATE lp_plates_backup AS t INNER JOIN ( SELECT plate_uid, brand, model, date_validated FROM lp_pictures_backup as parent WHERE brand <> '' AND date_validated = ( SELECT MAX(date_validated) FROM lp_pictures_backup ...
This is revolves around COLLATION rules (which are part of your locale). Per documentation: The C and POSIX collations both specify "traditional C" behavior, in which only the ASCII letters "A" through "Z" are treated as letters, and sorting is done strictly by character code byte values. Bold emphasis mine. These internal operators: ~<~, ...
Top 50 recent answers are included