Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
string queryStr = "Select * From Inventory ORDER BY foodID= @fID, inventoryID= @iID";
Posted
Comments
Sergey Alexandrovich Kryukov 3-Feb-14 11:20am    
Solve what?
—SA
[no name] 3-Feb-14 11:38am    
Select * From Inventory where foodID= @fID and inventoryID= @iID ORDER BY foodID,inventoryID

Go through some basic tutorial of sql to avoid trivial issues..

That depends on what you actually want to do - that won't work at all.
If you are trying to retrieve a subset of the records based on a criteria then perhaps:
C#
string queryStr = "SELECT * FROM Inventory WHERE foodID= @fID AND inventoryID= @iID";
If you are trying to order all the records by two columns then try:
C#
string queryStr = "SELECT * FROM Inventory ORDER BY foodID, inventoryID";

If you want some combination, then you need to explain exactly what combination you are looking for.
 
Share this answer
 
SQL
Select * From Inventory where  foodID= @fID and inventoryID= @iID ORDER BY foodID, inverntoryID
 
Share this answer
 
Comments
Thava Rajan 4-Feb-14 0:25am    
if its is filtered why the order by clause needed there
Karthik_Mahalingam 4-Feb-14 0:45am    
filter will do narrow down the results,
order by will order the records in such a fashion to display in asc or desc order.
Thava Rajan 4-Feb-14 0:47am    
thanks for your info
but here we just filter the foodid and inventoryid and again you just add the order by on it, is it needed?
Karthik_Mahalingam 4-Feb-14 0:52am    
see it depends on the design of the DB,
if FoodID is Primary KEy then no use of ORDER BY
all i wanted to show his , how to use filter and oRDER BY

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900