Select dataset except where values are in this other dataset
suggest changeThe two sides of EXCEPT must have the same number of columns and compatible types. EXCEPT returns distinct rows. MySQL before 8.0.31 has no EXCEPT. A single-quoted alias is not standard SQL.
--dataset schemas must be identical
SELECT 'Data1' AS ColumnName UNION ALL
SELECT 'Data2' AS ColumnName UNION ALL
SELECT 'Data3' AS ColumnName UNION ALL
SELECT 'Data4' AS ColumnName UNION ALL
SELECT 'Data5' AS ColumnName
EXCEPT
SELECT 'Data3' AS ColumnName
--Returns Data1, Data2, Data4, and Data5
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents