473,419 Members | 2,042 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,419 software developers and data experts.

How to use UNION ALL and SORT BY

Hi,

I have an asp site where I sell some products. Product categories are
stored in different tables. There are different asp product pages,
which collects data from these tables.
I have also created an all-product-page, which works fine with the
following sql query:

SELECT * FROM kaldoi
WHERE (id LIKE 'KALDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkdoi
WHERE (id LIKE 'MKDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkfut
WHERE (id LIKE 'MKFUT%' AND soldout <> 1)

This page lists all my products by product category.
I'd like to sort the results by "productid", however when I insert
'SORT BY productid' at the end of the statement, I receive the
following error message from my editor (FP2003):

Server error: Unable to retrieve schema information from the query:

SELECT * FROM kaldoi
WHERE (id LIKE 'KALDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkdoi
WHERE (id LIKE 'MKDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkfut
WHERE (id LIKE 'MKFUT%' AND soldout <> 1)
-------------------------------------------------------
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
operator) in query expression '(id LIKE 'MKFUT%' AND soldout <> 1)
SORT BY productid'.

Source: Microsoft OLE DB Provider for ODBC Drivers
Number: -2147467259 (0x80004005)
I couldn't solve it, though I have browsed through dozens of threads
here.
Any help will be appreciated

Nov 28 '05 #1
1 2434
It's:
ORDER BY productid

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<to******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,

I have an asp site where I sell some products. Product categories are
stored in different tables. There are different asp product pages,
which collects data from these tables.
I have also created an all-product-page, which works fine with the
following sql query:

SELECT * FROM kaldoi
WHERE (id LIKE 'KALDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkdoi
WHERE (id LIKE 'MKDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkfut
WHERE (id LIKE 'MKFUT%' AND soldout <> 1)

This page lists all my products by product category.
I'd like to sort the results by "productid", however when I insert
'SORT BY productid' at the end of the statement, I receive the
following error message from my editor (FP2003):

Server error: Unable to retrieve schema information from the query:

SELECT * FROM kaldoi
WHERE (id LIKE 'KALDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkdoi
WHERE (id LIKE 'MKDOI%' AND soldout <> 1)
UNION ALL
SELECT * FROM mkfut
WHERE (id LIKE 'MKFUT%' AND soldout <> 1)
-------------------------------------------------------
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
operator) in query expression '(id LIKE 'MKFUT%' AND soldout <> 1)
SORT BY productid'.

Source: Microsoft OLE DB Provider for ODBC Drivers
Number: -2147467259 (0x80004005)
I couldn't solve it, though I have browsed through dozens of threads
here.
Any help will be appreciated

Nov 28 '05 #2

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

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
9
by: (Pete Cresswell) | last post by:
I've got some SQL that works as far as returning a recordset from a series of UNION statements. viz: SELECT whatever UNION this UNION that UNION other
2
by: d2r2 | last post by:
Hi, I'm trying to run a nested (UNION) query against a MSAccessXP database (version 2002; build 10.6501.6714; SP3) In Access the SQL-statement executes just fine. When I run it in a asp-page I...
5
by: NAJH | last post by:
I've been trying to do a union with a subquery - I've made a different example which follows the same principles as follows: First bit brings back accounts which are in the top 10 to 15 by...
1
by: PATGMorris | last post by:
I've got a Union Query that pulls data from two different tables for chemistry and micro testing. The tables containing very similar data but for reasons not necessary here, cannot be put into one...
2
by: Barry Schwarz | last post by:
Given a union of the form union { T1 m1; T2 m2;}obj; where T1 and T2 are different scalar (non-aggregate) types. The C99 standard states that obj.m1 = value; if (obj.m2 ... invokes...
14
by: Clint Olsen | last post by:
I was wondering if it's considered undefined behavior to use a member of a union when it wasn't initialized with that member. Example: typedef unsigned long hval_t; hval_t hval_init(void) {...
1
by: needin4mation | last post by:
Hi, I have a select that uses union. The gridview populates fine with the two tables' returned data. But now I want to sort the resulting dataset as if it were one set of data, since I know of no...
3
by: SRK | last post by:
Hi, I wanted to use an anonymous union within an structure something like below - struct Test { union { std::string user; //char user; std::string role; //char role;
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.