I need to retrieve ListingId from the below table based on the search condition. Kindly help the best way to retrive the query for the conditions below
Note : ListingId
SELECT
t1.ListingID
FROM
TableX AS t1
JOIN --- 2nd JOIN
TableX AS t2
ON
t2.ListingID = t1.ListingID
JOIN --- 3rd JOIN
TableX AS t3
ON
t3.ListingID = t1.ListingID
WHERE
(t1.ExtraFieldID, t1.Value) = (@ExtraFieldID_search1, @Value_search1)
--- 2nd condition
AND
(t2.ExtraFieldID, t2.Value) = (@ExtraFieldID_search2, @Value_search2)
--- 3rd condition
AND
(t3.ExtraFieldID, t3.Value) = (@ExtraFieldID_search3, @Value_search3)
If you need 3 conditions, you'll need to join the table to itself one more time (so 3 times in total)