Eli ha scritto:
Hello,
Say I get these rows in a regular query:
col1 col2 col3 ----------------------- NULL B1 NULL NULL NULL NULL A3 B3 NULL A4 NULL C4 A5 B5 C5 NULL B6 C6
(It's important to keep the rows in that order). I want to get 1 row of the first non-null values from every column.. the row: A3 B1 C4.
Like the COALESCE function in MySQL, but on rows.
Please help...
-thanks, Eli
SELECT * FROM tab WHERE ISNULL(col1) LIMIT 1 UNION SELECT * FROM tab WHERE ISNULL(col2) LIMIT 1 UNION SELECT * FROM tab WHERE ISNULL(col3) LIMIT 1
In your case this will return only 2 rows because union remove duplicates and row 2 satisfy both query 2 and 3
Hope it helps francesco
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]