On Sat, 7 May 2005, Roger Baklund wrote: >Dan Bolser wrote: >> SELECT DISTINCT ROW(A,B) from a; >> >> While I am on a roll (of sorts) can I ask if the above syntax should be >> valid or not? > >If you mean the exact syntax above, I think not... it looks like ROW() >is a function taking two parameters in this case... what does the >function return? Is it an aggregate function?
Good question. I don't really know what the function is. You can see it in action here... http://dev.mysql.com/doc/mysql/en/row-subqueries.html "The expressions (1,2) and ROW(1,2) are sometimes called row constructors. The two are equivalent. They are legal in other contexts, too." >If the ROW() function was a synonym for the CONCAT() function, or worked >in a similar way, it might work, but what is the point? I know it is easy to fix given the example, but I want to nest the whole thing in an IF statement COUNT(DISTINCT IF(C=1,ROW(A,B),NULL)) AS x FROM a; Which is equivelent to ... COUNT(DISTINCT A,B) AS x FROM a WHERE C=1; But the former is more powerfull (if it worked). The following works (as suggested)... COUNT(DISTINCT IF(C=1,CONCAT(A,B),NULL)) AS x FROM a; But it isn't optimal because the DISTINCT can't make use of an index over A and B. I guess I should just stop complaining and make an AB column and put an index over it, but it just 'feels' like ROW should work here. Cheers > >> I have a feeling it should be valid (but isn't - it causes an error). >> >> Is this the correct behaviour? > >Try this: > >SELECT DISTINCTROW A,B from a; > >DISTINCTROW and DISTINCT are synonyms: > ><URL: http://dev.mysql.com/doc/mysql/en/select.html#id2828077 > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]