Hi guys, I have the following query in sql
SELECT
a1
FROM
dbo.myProductNames
WHERE
keycode = 40 OR keycode = 28 OR keycode = 32 OR keycode = 50
a1 = name I need information in the table to display the names that he requested in the query I set, so I need 40 to be first, then 28 onwards.
The reason for this is my code, which reads the results and stores in an array, which is then used to display on the form.
The table from which the SQL query arrives contains information stored in num order, so 28 will be read first, etc. etc.
As I said, I need to get the information in the order in which I entered the where clause.
I think there is something to do with nested Select statements, although I have never tried nested selects.
Or is there an easy way?
Any help would be great!
!
!!!!! UPDATE!!!!!
ok , , !
SqlCommand pgNameFill = new SqlCommand("SELECT a1, CASE keycode WHEN @pg1 THEN 1 WHEN @pg2 THEN 2 WHEN @pg3 THEN 3 WHEN @pg4 THEN 4 END AS SortOrder FROM dbo.myProductNames WHERE keycode IN (@pg1, @pg2, @pg3, @pg4) ORDER BY SortOrder ASC", conny1);
pgNameFill.Parameters.AddWithValue("@pg1", pg1);
pgNameFill.Parameters.AddWithValue("@pg2", pg2);
pgNameFill.Parameters.AddWithValue("@pg3", pg3);
pgNameFill.Parameters.AddWithValue("@pg4", pg4);
SqlDataReader readpg = pgNameFill.ExecuteReader();
! , , , !