Re: [PHP] RE: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
Santa wrote: MySQL don't know what is "UNION" http://dev.mysql.com/doc/mysql/en/UNION.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
MySQL don't know what is "UNION" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
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
[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
adwin wijaya wrote: Hi... I have an query for mysql that looks like: 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 ? http://dev.mysql.com/doc/mysql/en/UNION.html The types and lengths of the columns in the result set of a UNION take into account the values retrieved by all the SELECT statements. Before MySQL 4.1.1, a limitation of UNION is that only the values from the first SELECT are used to determine result column types and lengths. This could result in value truncation if, for example, the first SELECT retrieves shorter values than the second SELECT: mysql> SELECT REPEAT('a',1) UNION SELECT REPEAT('b',10); +---+ | REPEAT('a',1) | +---+ | a | | b | +---+ That limitation has been removed as of MySQL 4.1.1: mysql> SELECT REPEAT('a',1) UNION SELECT REPEAT('b',10); +---+ | REPEAT('a',1) | +---+ | a | | bb| +---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
Why not ask a MySQL mailing list? [snip] .. is this mysql bug ? [/snip] -- -- David Green Information Centre, Central Science Laboratory Sand Hutton, York, YO41 1LZ Phone: +44 (0)1904 462388 (GTN: 5129 2388) Fax:+44 (0)1904 462111 E-Mail: [EMAIL PROTECTED] -- CSL email disclaimer: http://www.csl.gov.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
[snip] I have an query for mysql that looks like: 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 ? [/snip] This should probably be asked on the MySQL list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[suspicious - maybe spam] [PHP] [suspicious - maybe spam] strange in MySQL Query.
Hi... I have an query for mysql that looks like: 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 ? -- === Best Regards Adwin Wijaya http://masterkuya.blogspot.com/ http://www.kuya-kuya.net http://www.e-rhema.net === -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php