Order the resulting rows based on multiple columns

Viewed 59

I have to put down the lines that have two distinct fields with value = 0

Let me explain, all records that have stock_it=0 and stock_eu=0 must go to the bottom of the results

I have used this solution, however, it is not strictly correct because it puts down even rows that do not have both values = 0

$dati = mysql_query("
    SELECT      * 
    FROM        $tb_article
    ORDER BY
        FIELD($tb_art.article_status,'n') DESC, 
        FIELD($tb_art.article_stock_it,'0') ASC, 
        FIELD($tb_art.article_stock_eu,'0') ASC,  
        $tb_art.article_rank
");
  1. article_status=n indicates new products and they have to stay on top!
  2. Push to bottom all the article that have stock IT and stock EU = 0 (products not available)
  3. In the end, order the rest of the articles according to the rank assigned
2 Answers
Related