Keep query order results view as entered in the sql view using Access 2007

醉酒当歌 提交于 2019-12-11 17:45:15

问题


How do I keep the query order results as in the sql view the same. I use the following sql to obtain the results

SELECT TableName.NumBR
FROM TableName
WHERE 
NumBR = ""
OR NumBR Like "3101"
OR NumBR Like "3541"
OR NumBR Like "4381"
OR NumBR Like "AS3281"
OR NumBR Like "4260"
OR NumBR Like "4315"
OR NumBR Like "4330"
OR NumBR Like "4382"
OR NumBR Like "9410"
OR NumBR Like "9570"
OR NumBR Like "AS3710"
OR NumBR Like "AS4450"
OR NumBR Like "K400"
OR NumBR Like "3100"
OR NumBR Like "3130"
OR NumBR Like "3280"
OR NumBR Like "3495"
OR NumBR Like "3540"
OR NumBR Like "3610"
OR NumBR Like "3700"
OR NumBR Like "4110"
OR NumBR Like "4200"; 

but the results are always resorted in ascending order when I would like the order to remain as entered in the sql view.


回答1:


You have not selected an order, you have created a where statement. You can use a temporary table with an autonumber for your criteria, then you can use the autonumber for your order.

SELECT TableName.NumBR
FROM TableName
INNER JOIN temp 
ON TableName.NumBR = Temp.NumBR
ORDER BY Temp.ID


来源:https://stackoverflow.com/questions/11935615/keep-query-order-results-view-as-entered-in-the-sql-view-using-access-2007

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!