mysql - Get SQL result ordered by a column value -


i'm trying results ordered column value. have basic query:

select `product_id`,        (select `name`           `specifications` s          `specification_id` = sp.`specification_id`) specification,        `value`   `specs-product` sp  `product_id` = '4'        , ( `specification_id` = '88'               or `specification_id` = '103'               or `specification_id` = '18'               or `specification_id` = '15'               or `specification_id` = '157'               or `specification_id` = '89'               or `specification_id` = '9'               or `specification_id` = '223'               or `specification_id` = '224'               or `specification_id` = '29'               or `specification_id` = '87'               or `specification_id` = '219'               or `specification_id` = '218'               or `specification_id` = '220' )  

i've column name in table specifications called priority. need result ordered priority values.

i've tried add order s.'priority' didn't work. how can this?

table structure follows:

specifications

+------------------+------+----------+ | specification_id | name | priority | +------------------+------+----------+ | 1                | abc  |        5 | | 2                | xxxx |        2 | | 3 ababab         | 3    |          | +------------------+------+----------+ 

products table

+------------+------------+--+ | product_id | reference  |  | +------------+------------+--+ |          1 | abc        |  | |          2 | xxxx       |  | |          3 | ababab     |  | +------------+------------+--+ 

add

order sp.'priority' 

assuming in table. if doesn't work need schema.

edit

select `product_id`, s.name specification, `value`  `specs-product` sp  inner join `specifications` s on s.`specification_id` = sp.`specification_id` `product_id`='4'  , (s.`specification_id`='88' or  s.`specification_id`='103' or  s.`specification_id`='18' or  s.`specification_id`='15' or  s.`specification_id`='157' or  s.`specification_id`='89' or  s.`specification_id`='9' or  s.`specification_id`='223' or  s.`specification_id`='224' or  s.`specification_id`='29' or  s.`specification_id`='87' or  s.`specification_id`='219' or  s.`specification_id`='218' or  s.`specification_id`='220') order s.priority 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -