Subject | Re: [firebird-support] Select with UNION problems |
---|---|
Author | Ivan Prenosil |
Post date | 2004-09-06T15:19:48Z |
Or do not use UNION at all, try something like
SELECT SO.IDOS as ID, CASE WHEN SO.IDCLIENT IS NOT NULL THEN CL.NAMECLI ELSE 'Empty' END as CLIENT
FROM SO SO LEFT JOIN CLIENT CL ON SO.IDCLIENT = CL.IDCLIENT
Ivan
SELECT SO.IDOS as ID, CASE WHEN SO.IDCLIENT IS NOT NULL THEN CL.NAMECLI ELSE 'Empty' END as CLIENT
FROM SO SO LEFT JOIN CLIENT CL ON SO.IDCLIENT = CL.IDCLIENT
Ivan
> When using SELECT with UNION like the example, I get an error. I've
> made some tests and I think the problem is that the string column
> CLIENT must match exactly the same SIZE. But It's a VARCHAR in the
> dababase, so how I have to do ?
>
> SELECT SO.IDOS as ID, 'Empty' as CLIENT
> FROM SO SO
> WHERE
> SO.IDCLIENT IS NULL
> UNION
> SELECT SO.IDOS as ID, CL.NAMECLI as CLIENT
> FROM SO SO, CLIENT CL
> WHERE
> SO.IDCLIENT = CL.IDCLIENT
> SO.IDCLIENT IS NOT NULL
>
> The error is :
> ISC Error code : 335544569
>
> SQL error -104
> Invalid command
> Data type unknown
>
> Firebird WI-V1.5.0.4306 Firebird 1.5
>
> Regards