这是我的选择查询我想通过首先获取带有两个字段的记录来进行排序,我希望通过transType进行排序,然后使用transDate进行排序 我已经通过这两个字段获得了订单,但它无效。
我知道有一些愚蠢的错误,但我找不到它
SELECT tranjectionId,date_format(transDate,'%d-%m-%Y') AS transDate,motiAmount,
transType,tranjection.partyId,item.itemName,gwt,loss,netwet,
party.partyName,melting,westage,finewet,rhodium,amount,bhav
FROM tranjection
LEFT JOIN party ON party.partyId = tranjection.partyId
LEFT JOIN item ON item.itemId = tranjection.itemId
WHERE tranjection.partyId = $_REQUEST['partyId']
AND transDate >= '$fromDate'
AND transDate <= '$toDate'
ORDER BY transType = 'I',
transDate
答案 0 :(得分:1)
这是您的order by
:
ORDER BY transType = 'I',
transDate
表达式transType = 'I'
是一个布尔表达式。当解释为整数时,&#34; 0&#34;是假的,&#34; 1&#34;是真的。因此,错误值首先出现在排序中,然后出现真值。
您只想对降序进行排序:
ORDER BY (transType = 'I') DESC,
transDate