我到處搜索了這個地方,但找不到任何解決方案,我需要在下面的sql語句中首先列出一個特定的城市,如'紐約',我試圖放置 ORDER BY CASE City.name_en WHEN'紐約'THEN 1 ELSE 2 END,City.name_en 在內部的sql語句但沒有工作,有沒有解決這個問題的任何解決方法?首先列出具體的值
SELECT * FROM (
SELECT RTRIM(Organization.name_en) as '@name','flag.png' AS '@flag',
RTRIM(Country.name_en) as 'country',RTRIM(city.name_en) as 'city',Organization.id as 'OrganizationID',
ROW_NUMBER() OVER (ORDER BY sequence_num) AS RowNum
FROM Organization
LEFT JOIN City ON City.id = city_id
LEFT JOIN Country ON country.id = Organization.country_id
LEFT JOIN Industry ON Industry.id = Industry_id
WHERE
(industry_id [email protected]_id OR Coalesce(@industry_id,'') = '')
AND (Organization.name_en LIKE '%' + @OrganizationName + '%' OR Coalesce(@OrganizationName,'') = '')
) AS SOD
WHERE SOD.RowNum BETWEEN ((@PageNumber-1)*@RowsPerPage)+1
AND @RowsPerPage*(@PageNumber)
FOR XML PATH('organization'), ROOT('organizations')
這是一個不是MySql的SQL Server問題! – user2638062
檢查了這一點 - http://www.youdidwhatwithtsql.com/ordering-by-column-value-in-sql-server-mysql/384/ – unknown
我已經試過這個,但沒有得到預期的結果,我已經提到這個在我的問題 – user2638062