order by 不能在两个字段中正常工作 [英] order by is not working properly with two fields
问题描述
这是我的选择查询,我想先通过获取两个字段的记录进行排序,然后我想使用 transType 排序,然后使用 transDate我已经收到了这两个字段的命令,但它不起作用.
this is my select query i want to order by fetch record with two fields first and i want to order by with transType and after that with transDate i am already given order by with this two fields but it is not working.
我知道有一些愚蠢的错误,但我找不到
i know that there is something silly mistake but i can not find it
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
推荐答案
This is your order by
:
This is your order by
:
ORDER BY transType = 'I',
transDate
表达式 transType = 'I'
是一个布尔表达式.当解释为整数时,0"为假,1"为真.因此,排序中首先出现假值,然后是真值.
The expression transType = 'I'
is a boolean expression. When interpreted as an integer, "0" is false, and "1" is true. Hence, false values appear first in the sort, then true values.
您只想降序排序:
ORDER BY (transType = 'I') DESC,
transDate
这篇关于order by 不能在两个字段中正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!