I having an issue trying to form query for the question below:
SQL statement to find all table A which have a value of table B appearing more than 1
cur.execute("SELECT Table1.Column FROM Table 1 WHERE Table1.Column like %(SELECT Distinct value FROM table 2 WHERE type like '%Soooos%')% ")
after compiling the cur fetch nothing. so my did form the query correctly, please help thanks
Advertisement
Answer
SELECT * FROM table_a WHERE table_a.id IN (SELECT somefield FROM table_b GROUP BY somefield HAVING COUNT(*) > 1);