-1
我有一個數據庫表。mySql如何按列值排序選定結果
在這個表中我有列名User_Id。
我想3級命令的結果:
- 最初的結果應該是特定的用戶ID 2 + 3。按一些列排序。
是有可能使一些像這樣的查詢:
Select * From User
Order By User_Id = 1223, Start_Date, Last_Name;
UPDATE:
這是我的查詢:
SELECT Events.Event_Id, Events.Name as Event_Name, Events.Place, Events.Start_Time, Events.End_Time, getEventInvitedUsers(Events.Event_Id) as Invited_Users, getEventAttendingUsers(Events.Event_Id) as Attending_Users,
Users.Facebook_Id, Users.Name as User_Name, Users_In_Events.Is_Attending as Is_Attending
FROM Users_In_Events
Left Join Events
On Users_In_Events.Event_Id = Events.Event_Id
Left Join Users
On Events.Facebook_Id = Users.Facebook_Id
WHERE
Users_In_Events.Facebook_Id = 613714903
And
(Events.Start_Time > now()
Or
(Events.Start_Time > now() And Events.End_Time < now()))
Order By Events.Facebook_Id= 613714903, Users_In_Events.Is_Attending, Events.Start_Time;
查詢返回的所有排序來自事件表的事件。
我想知道,如果它是可能的,我寫在上面的代碼Events.Facebook_Id= 613714903
你能重新表達一下你的問題嗎? – HichemSeeSharp
有一種方法,但你的SQL不是它。顯示示例輸出並解釋如何對它進行排序。 – AgRizzo
是的......這是可能的,但你不能使用=操作符的原因順序..所以試試這個選擇*從用戶 其中User_Id = 1223 Order By User_Id,Start_Date,Last_Name; –