我必须查询285个ID和路径。乍一看,ID没有真正的模式,我不确定是否有办法通过简单而优雅的查询实现这一目标。
但是,我不是专家,仍在学习SQL。所以,希望得到一些指导。
以下是我想要匹配的前50个参赛作品的摘录:
ID path
261617 /About/Factfile
31 /About/Factfile/18060
761 /About/Factfile/18060/11550
762 /About/Factfile/18060/11552
763 /About/Factfile/18060/11555
35 /About/Factfile/scotlandsnapshot
63 /About/Government/background
74 /About/Government/sgprevious
1555 /About/Government/sgprevious/2007-2011
328782 /About/Government/sgprevious/2011-2016
1553 /About/Government/sgprevious/sgprevious1999-2003
1554 /About/Government/sgprevious/sgprevious2003-2007
46 /About/Information/expenditure
271169 /About/Information/expenditure/GPC
329992 /About/Information/expenditure/GPC/epc500-16-17
297247 /About/Information/expenditure/GPC/GPC
297249 /About/Information/expenditure/GPC/GPC/GPC
297243 /About/Information/expenditure/GPC/GPC500
271168 /About/Information/expenditure/over-25k
1550 /About/Information/expenditure/over-25k/background
1551 /About/Information/expenditure/over-25k/reports
22138 /About/Information/expenditure/over-25k/reports/2011-2012
291275 /About/Information/expenditure/over-25k/reports/expenditure
22137 /About/Information/expenditure/over-25k/reports/Expenditure2010
266779 /About/Information/expenditure/over-25k/reports/reports
303729 /About/Information/expenditure/over-25k/reports/Test
316271 /About/Information/expenditure/over-25k/reports/Test1
276826 /About/Information/expenditure/PSRA2010
293815 /About/Information/expenditure/PSRA2010/2011-12-PSRduties
318093 /About/Information/expenditure/PSRA2010/duties-13-14
311621 /About/Information/expenditure/PSRA2010/duties-2012-13
294347 /About/Information/expenditure/PSRA2010/historic-efficiency-reports
276831 /About/Information/expenditure/PSRA2010/historicexpenditure10-11and11-12
261611 /About/People
23769 /About/People/14944/Events-Engagements/MinisterialEngagements
148038 /About/People/14944/Events-Engagements/MinisterialEngagements/2008
148037 /About/People/14944/Events-Engagements/MinisterialEngagements/2009
148036 /About/People/14944/Events-Engagements/MinisterialEngagements/2010
148039 /About/People/14944/Events-Engagements/MinisterialEngagements/201112
268177 /About/People/14944/Events-Engagements/MinisterialEngagements/2012-13
296737 /About/People/14944/Events-Engagements/MinisterialEngagements/2013-14Engagements
304646 /About/People/14944/Events-Engagements/MinisterialEngagements/2014-15Engagements
317634 /About/People/14944/Events-Engagements/MinisterialEngagements/MinisterialEngagements
987 /About/People/14944/Special-Advisers
254426 /About/People/14944/Special-Advisers/gifts-hospitality
1048 /About/People/14944/travel
23479 /About/People/14944/travel/airtravel
23481 /About/People/14944/travel/ferrytravel
23483 /About/People/14944/travel/MinisterialCarJourneys
148029 /About/People/14944/travel/MinisterialCarJourneys/2010-11
这应该分为2个查询,1个用于ID,另一个用于路径吗?
先谢谢大家,如果这是n00b的话,请原谅我。
亲切的问候,
V
答案 0 :(得分:0)
SELECT id, path
FROM tbl
ORDER BY path
LIMIT 285;