I am working on an SQL query that would pull rows from three tables and order them by date. The structure of the tables is:
id - auto incrememnting integer
inquiry - the referenece to the inquiry that this comment relates to
comment - text
The problem is, inquiries can have multiple comments and I receive output with duplicating inquiry numbers. I would like a result set with only unique/distinct inquiry numbers, but including the word DISTINCT after each select does not solve this, any ideas?
(SELECT * FROM abc) UNION (SELECT * FROM def) UNION (SELECT * FROM ghi) ORDER BY `date` DESC