Hi all,

THere is no intersect statement in MySQL. I figure out a workaround as shown below. However, I am not sure if it is correct or not. Please help.

SELECT * FROM (
	SELECT DISTINCT col1 FROM t1 WHERE...
	UNION ALL
	SELECT DISTINCT col1 FROM t1 WHERE...
) AS tbl
GROUP BY tbl.col1 HAVING COUNT(*) = 2

yes that should work

you could also use a subselect on the table

select DISTINCT col1 FROM t1 WHERE ..... and col1 in (select DISTINCT col1 from t1 WHERE .....)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.