473,503 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with a simple union

I am relatively new to DB2 and having a problem with a simple union
statement.

Running Db2UDB version 8.1.1 on Aix 5.1

The union and union all SQL statements I am running produce the same
results. No duplicates are being eliminated in the union.

To verify, I ran SQL with union statements against system tables.

Same result.

An example:

db2 "select tabschema from syscat.tables
union
select tabschema from sysstat.tables"

db2 "select tabschema from syscat.tables
union all
select tabschema from sysstat.tables"

Both queries produce the same results with duplicates in both.

Both tabschema columns are in the same location (1st) and both are
varchar(128).

What am I doing wrong? Would appreciate any thoughts.

Thanks
Gerry
sn********@sbcglobal.net
Nov 12 '05 #1
2 10730
Not really sure why you are seeing what you see - if I try the exact same on DB2 UDB V8.1
FP #7 (V8.2) I get the expected results:

C:\>db2 "select tabschema from syscat.tables union select tabschema from sysstat.tables"

TABSCHEMA
-------------------------------------------------------------------------------
SYSCAT
SYSIBM
SYSSTAT
SYSTOOLS

4 record(s) selected.

The UNION ALL SELECT returns 413 records with duplicates ... as you can see the above did
not return duplicates ...

Strange ... but does not seem you are doing anything wrong ...

--

Bob
Engagement Specialist - DB2 Information Management Software - IBM Software Group
IBM Toronto Lab
[My comments are solely my own and are not meant to represent an official IBM position -
ask my cat!]

"Gerry" <sn********@sbcglobal.net> wrote in message
news:70*************************@posting.google.co m...
I am relatively new to DB2 and having a problem with a simple union
statement.

Running Db2UDB version 8.1.1 on Aix 5.1

The union and union all SQL statements I am running produce the same
results. No duplicates are being eliminated in the union.

To verify, I ran SQL with union statements against system tables.

Same result.

An example:

db2 "select tabschema from syscat.tables
union
select tabschema from sysstat.tables"

db2 "select tabschema from syscat.tables
union all
select tabschema from sysstat.tables"

Both queries produce the same results with duplicates in both.

Both tabschema columns are in the same location (1st) and both are
varchar(128).

What am I doing wrong? Would appreciate any thoughts.

Thanks
Gerry
sn********@sbcglobal.net

Nov 12 '05 #2
Turns out it was a problem with the way the statement was being parsed
by Putty, my telnet client.

Even weirder, after 2 days of parsing it in a manner which gave union
all results no matter how it was entered, it suddenly stopped.
Thanks
Gerry

Nov 12 '05 #3

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

Similar topics

3
6083
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection...
3
3584
by: junlia | last post by:
We are using ACORD xml schema standard, and we need to add to it, so we choose to redefine ACORD xml schema. One of the problems that I ran into is how to add some values to an emumerated list. ...
6
2020
by: atefshehata | last post by:
hi all, i'm new to db2 and i have a simple question .. Using db2 ver 7. i have a table named 'Locations' with three varchar columns LocId,LocDesc,LocType when i execute >
2
1517
by: Adam Louis | last post by:
Hi, I'm running a query unifying two relatively simple selections. The problem is that each selection, on its own, completes instantaneously, but, unified, the processing takes upwards of 30...
1
2618
by: aredo3604gif | last post by:
On Sun, 10 Apr 2005 19:46:32 GMT, aredo3604gif@yahoo.com wrote: >The user can dynamically enter and change the rule connection between >objects. The rule is a "<" and so given two objects: >a <...
20
2461
by: Brian Tkatch | last post by:
An ORDER BY a simple-integer inside a FUNCTION, results in SQL0440N, unless the FUNCTION expects an INTEGER as its parameter. For example: DECLARE GLOBAL TEMPORARY TABLE A(A CHAR(1)) INSERT INTO...
5
1253
by: hubmei75 | last post by:
Hello, I have a simple table containing adresses. A sample view of the table is id name city -------------------------------- 100 Meier New York 101 Meier Tokyo 110 ...
4
4131
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...
4
2099
by: Thomas | last post by:
Hello, I am a CS student and I want to write simple lisp interpreter. The code should be entierly in C. I don't want to use any compiler generators like Bison or Yak, since wrinting this in...
0
7093
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
7349
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
7467
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
5594
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,...
1
5022
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...
0
4688
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...
0
1521
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 ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
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...

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.