For this,
>>>> 2012/10/04 16:13 +0200, MAS! >>>>
IF(GROUP_CONCAT(DISTINCT secA.sec_code  SEPARATOR '|') is null,                 
                                                                                
           
               IF(GROUP_CONCAT(DISTINCT secB.sec_code  SEPARATOR '|') is null, 
settore, GROUP_CONCAT(DISTINCT secB.sec_code  SEPARATOR '|')),                  
                           
                 GROUP_CONCAT(DISTINCT secA.sec_code  SEPARATOR '|') ) as 
settore,  
<<<<<<<<
you really want

IFnull(GROUP_CONCAT(DISTINCT secA.sec_code  SEPARATOR '|'),
               IFnull(GROUP_CONCAT(DISTINCT secB.sec_code  SEPARATOR '|'), 
settore)) as settore,  

The operation
If this is not null use this, else use that
is far, far too common in SQL for there not to be a function for it.

As for your original question, note this from the MySQL HTML documentation:


8.4. User-Defined Variables

...
As a general rule, you should never assign a value to a user variable and read 
the value within the same statement. You might get the results you expect, but 
this is not guaranteed. The order of evaluation for expressions involving user 
variables is undefined and may change based on the elements contained within a 
given statement. In SELECT @a, @a:=@a+1, ..., you might think that MySQL will 
evaluate @a first and then do an assignment second. However, changing the 
statement (for example, by adding a GROUP BY, HAVING, or ORDER BY clause) may 
cause MySQL to select an execution plan with a different order of evaluation. 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to