I'm writing a ticket program in vb.net using MySQL.
What I want is to use the Statename that a ticket can have (open/closed/on hold/etc) that I get from query 1, and use it in query 2 to get a list of all statenames, with the result of the first query as first item.
I now use 2 queries after each other, but i'm sure it can be done in 1 query.
Query 1:
SELECT StateName FROM Tickets t JOIN States s ON s.stateID = t.StateID WHERE TicketNumber = & *intTicketNumber* --> Result = "Open"
Query 2:
SELECT StateName from States ORDER BY(case when StateName = '" & *StrStateName* & "' then 0 else 1 end) , StateName desc The Desired result of the combined query should be:
- open
- assigned
- closed
- on hold
How Can I combine there 2 queries? Any help would really be appreciated!