473,809 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "xxxxxxxxxxxxxx xx",
"xxxxxxxxxxxxxx xx",
...

And then in the code that uses the results, ignore any rows that have
"xxxxxxxxxxxxxx xx" 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 2086
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 "12345678901234 567";
SELECT foo FROM unionResult;
+------------------+
| foo |
+------------------+
| foo |
| fnord |
| 123456789012345 6 |
+------------------+

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
5301
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 specification for each column (e.g. printf(%10s %25s %15s\n", pszCol1, pszCol2, pszCol3)). My problem is that when a string is longer the column's width, it overflows the column and takes the table out of alignment. What I want it to do is word-wrap...
0
2627
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 header row - and they conflict. The sortable column apparently uses the generic style for <a> elements and the rest of the header uses "headerRow". Can anyone tell me how to get consistent styles for each column in my datagrid header?
17
7440
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 columns in it but i need to add a sixth column which will be my checkbox column - any help or pointers with this would be great
7
3948
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 column partition_id in these tables. Now, if I define this column as NOT NULL, I notice that the loading this view is almost twice fast as if I had defined it NULLABLE. Can anyone explain? What exactly is DB2 doing in each of the case when...
7
4182
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 in each of the columns. For example, with the following dataset: id, col1, col2, col3, col4, col5, col6 1,2,3,4,5,6,7 2,8,6,5,4,3,2 3,2,3,9,4,2,1 I want a query to generate the following output: 1,7
2
10408
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 actually happens is... when the Text size is too big... the column
31
3117
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 like the middle column just to use up that space instead. Any way this is possible? Thanks for your help, it is highly appreciated!
1
4204
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 Time, ConcertPlace AS Place FROM Concerts UNION SELECT EventName AS Name, EventDate AS Date, EventTime AS Time, EventPlace AS Place FROM Events ORDER BY Date, Time now i'd like to add two things to this statement: 1. a column that indicates...
0
1627
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 dropdownbox. However, after I sort the gridview by clicking the B column generated by SDS1 then change to SDS2, error message will be "Cannot find column B". Does any one have ideas about this? Here is the simplified code:
0
9601
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.