473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

column width in union

Hi

Column width in a series of UNIONs is determined by the width of the
first SELECT. Here is an example:

mysql> ( SELECT "foo" ) UNION ( SELECT "fnord" );
+-----+
| foo |
+-----+
| foo |
| fno |
+-----+
2 rows in set (0.00 sec)

This is in MySQL 4.0.21.

In my real queries, I cannot know ahead of time the maximum length of
any column as returned by any of the SELECT blocks. My workaround is
to start my UNION chain with a

SELECT "xxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxx",
...

And then in the code that uses the results, ignore any rows that have
"xxxxxxxxxxxxxxxx" in them. This is extremely kludgy.

There was as thread from 2003-08-24 with the subject "Union and Order
By give strange results in Mysql 4.0.13" which describes this problem.
It was unresolved (only workarounded) over a year ago.

Does anyone know of a real fix?

-Michal
Jul 20 '05 #1
1 2068
mikeg wrote:
Column width in a series of UNIONs is determined by the width of the
first SELECT. ... Does anyone know of a real fix?


I thought of using CAST(foo as CHAR(16)), but that seems to be an error.

How about using a temporary table?

CREATE TEMPORARY TABLE unionResult ( foo CHAR(16 );
INSERT INTO unionResult SELECT "foo";
INSERT INTO unionResult SELECT "fnord";
INSERT INTO unionResult SELECT "12345678901234567";
SELECT foo FROM unionResult;
+------------------+
| foo |
+------------------+
| foo |
| fnord |
| 1234567890123456 |
+------------------+

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: nimdez | last post by:
Hi, I am working on an existing code base in which a lot of data displayed to the user is formatted in tables. Most tables are printed row-by-row using printf() with "%s" print conversion...
0
by: cedoucette | last post by:
I just wrote code to support sortable columns in a datagrid. It seems to work fine; but, it doesn't look right. The problem is that I have a generic style for links and a different style for the...
17
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5...
7
by: Rajesh.............................. | last post by:
What is the impact of using a nullable column vs a not nullable column for partitioning a Union ALL View? I have a Union ALL View with ten underlying tables unioned based on different values for a...
7
by: Mathew Butler | last post by:
Suppose I have a table t with columns id, col1, col2, col3, col4, col5, col6 all numeric. I want to query the table and for each value of col<x> in the resultset I want to identify the largest value...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
31
by: Sarita | last post by:
Hello, this might sound stupid, but I got a really nice homepage template which unfortunately is a 3-Column Fixed Width CSS format. Now I don't have any content for the right column and would...
1
by: BlackMustard | last post by:
hi all, i am currently using the following union select statement to select records from two of my tables to a gridview in asp.net: SELECT ConcertName AS Name, ConcertDate AS Date, ConcertTime AS...
0
by: Allan | last post by:
Hi, I am having trouble when I dynamically assign sqldatasources to a gridview. If I do not sort the gridviews, everything runs well even when I change the gridview's sqldatasource by changing the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.