adwin wijaya wrote:
> SELECT "group" as type FROM mytable WHERE id ="101010"
> UNION
> SELECT "individual" as type FROM myothertable WHERE id="101010"
>
> The strange result if only one result displayed from myothertable, so
> the "type" will become "indiv" instead of individual.
>
> But when I tried to switch the query become :
>
> SELECT "individual" as type FROM myothertable WHERE id="101010"
> UNION
> SELECT "group" as type FROM mytable WHERE id ="101010"
>
> it could displaye the result correctly. I dont know why .. is this mysql
> bug ?

Where's the PHP part?

The data type of your return columns MUST MATCH in a UNION.

The data type of "group" would be...  char(5) since it has no inherent
data type.

So when you put "group" first, MySQL uses char(5)

When you put "individual" first, MySQL uses char(10)

You can play with this some more with longer/short strings to verify.

If you force the type of 'group' to be, say, varchar(255) the discrepency
will disappear.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to