473,395 Members | 1,613 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.

Problem using MyODBC (Linux version) - bracketed UNION

Dear All

I've come across a strange issue when using UNION via MyODBC on my
Fedora linux box (I'm using MySQL 4.1.3-standard-beta)

**This doesn't work:

(select a from tbl_name where a=10 and b=1 order by a)
union
(select a from tbl_name where a=11 and b=2 order by a)
order by 1

(took this straight from the MySQL manual)

**Removing parentheses doesn't work either:

select a from tbl_name where a=10 and b=1 order by a
union
select a from tbl_name where a=11 and b=2 order by a
order by 1

**But this does work:

select a from tbl_name where a=10 and b=1
union
select a from tbl_name where a=11 and b=2
order by 1
- so it appears that ORDER BY is not allowed in an individual select
when it is being amalgamated with UNION (or UNION ALL).

Interestingly, the first statement works fine when executing from the
MySQL command line.

Has anyone else spotted this, and is there a workaround (other than
not ordering select clauses that are UNIONed together)?

Regards
Adrian
Jul 20 '05 #1
1 2093
Adrian wrote:
- so it appears that ORDER BY is not allowed in an individual select
when it is being amalgamated with UNION (or UNION ALL).


It could be that ODBC is doing some pre-parsing to ensure valid SQL.
The feature of ordering each component query and then ordering the
resulting union may be a nonstandard feature (I'm not certain of this),
and should rightly be disallowed in standard SQL.

In any case, why are you trying to order each query if you're just going
to re-order the resulting union? The preliminary ordering is
effectively a no-op, and therefore a waste of work.

Regards,
Bill K.
Jul 20 '05 #2

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

Similar topics

1
by: Adrian | last post by:
Dear All I've come across a strange issue when using UNION via MyODBC on my Fedora linux box (I'm using MySQL 4.1.3-standard-beta) **This doesn't work: (select a from tbl_name where a=10...
1
by: Boris Wilhelms | last post by:
Hello all, at first, sorry for my bad English, I’ll give my best  We have a strange problem reading Text- and VarChar-Fields. Our configuration: -Windows 2003 Server -MySQL Server 3.23.36...
6
by: Murtix Van Basten | last post by:
HI all, I am trying to migrate a database from mysql to mssql2k. I use myODBC to connect to mysql server to pull the database from DTS and insert in to sql server. But in mysql server, there is...
5
by: Dave Townsend | last post by:
Hi, I'm trying to port a piece of code from Windows to Linux, the following segment illustrates the coding problemI have: Under Linux, the reinterpret_cast line doesn't compile, the compiler...
9
by: zMisc | last post by:
When I try to update record, I kept getting this error: Row cannot be located for updating. Some values may have been changed since it was last read. No other users are accessing the database...
6
by: Piotr | last post by:
Hi, I have following problem: I use a form in excel to send data into mysql server, everything is ok unless I have to deal with decimals or data fields, this simple are not recognized. For...
7
by: Bob Stearns | last post by:
Several weeks ago I asked what comments I could pass to DB2 in a SELECT statement. I don't remember whether I said via PHP/ODBC. I was assured that both /* */ style comment blocks and -- comment...
4
by: google | last post by:
Hi Hope someone can help me with this - have been staring at this problem all day, and with the cold I've got, just don't seem to be able to figure it out! I've got two tables, here with some...
3
by: sp3d2orbit | last post by:
I've read the MySQL licensing material and what I've found online, but I'm still unclear about when I have to pay MySQL for a license. Scenario: I've created an application that stores some data...
5
by: Control Freq | last post by:
Hi I connect to my MySQL database using MyODBC. I have a table called 'log' in a database called 'home'. When I try to do an insert like this: insert into log (userid,event,event_date) values...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.