I need a SQL Statement to use IN operator within the items with "And" connected.
SELECT * from tbl_Users WHERE id in [1,2,3]
is equivalent to:
SELECT * from tbl_Users WHERE (id=1) or (id = 2) or (id = 3)
What I need is to generate using IN operator (or equivalent):
SELECT * from tbl_Users WHERE (id=1) AND (id = 2) AND (id = 3)
Because I collect all the IDs (ex: [1,2,3,4,5]) in one string and search with it in the DB.
ID is always a primary key
The case is I have a table which has all countries, and each country has several electrical standards in separate table.
Example: Germany requires always "standard1" and "standard2" USA required always "Standard1" and "standard3" France required always "Standard2"
If the user in C# application search for a country which has "Standard2", the system should give him Germany and France.
BUT If the user wants countries with "Standard1" AND "standard2", the system should only give him Germany. -> because of "AND"
My Query was
Select * from [tables and joins] where STANDARD_id IN [1,2]
[1,2] is a concatenated list which the user already choose from a list of standards.