Skip to content Skip to sidebar Skip to footer

Query Results Based On Multiple Records Using Compound Primary Key

What is the best way to get records from the database based on the selected primary keys? I am able to get the primary keys of the selected (checked) rows from a gridview, and now

Solution 1:

You can do this in a single query by using adding an OR clause for each trio of ids (i.e. for each selected row in your gridview). For example:

SELECT whatever FROM Table1 WHERE (KeyCol1=val1-1 AND KeyCol2=val1-2 AND KeyCol3=val1-3) OR (KeyCol1=val2-1 AND KeyCol2=val2-2 AND KeyCol3=val2-3) OR .. etc

Post a Comment for "Query Results Based On Multiple Records Using Compound Primary Key"