Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 11th, 2006, 11:05 AM
usenet@kikobu.com
Guest
 
Posts: n/a
Default "... WHERE (a, b) != (1,2) AND (a,b) != (1,3) ..."


Hi.

I would like to retrieve all records from a table except these where
the (a, b) combination has one of a series of specific values. For
example, in MySQL I can given the table:

a b
1 2
1 3
3 4

Do:

SELECT a, b
FROM tbl
WHERE (a, b) != (1,2) AND (a, b) != (3,4)

And get result:

1 3

Whats the DB2 equivalent?

Thanks.

Morten

  #2  
Old August 11th, 2006, 12:05 PM
Knut Stolze
Guest
 
Posts: n/a
Default Re: "... WHERE (a, b) != (1,2) AND (a,b) != (1,3) ..."

usenet@kikobu.com wrote:
Quote:
>
Hi.
>
I would like to retrieve all records from a table except these where
the (a, b) combination has one of a series of specific values. For
example, in MySQL I can given the table:
>
a b
1 2
1 3
3 4
>
Do:
>
SELECT a, b
FROM tbl
WHERE (a, b) != (1,2) AND (a, b) != (3,4)
>
And get result:
>
1 3
>
Whats the DB2 equivalent?
DB2 only supports the equality comparison:
http://publib.boulder.ibm.com/infoce...n/r0000747.htm

So you'll have to simply transform the above predicate.

NOT ( (a, b) = (1, 2) OR (a, b) = (3, 4) )

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
  #3  
Old August 11th, 2006, 02:05 PM
Serge Rielau
Guest
 
Posts: n/a
Default Re: "... WHERE (a, b) != (1,2) AND (a,b) != (1,3) ..."

Knut Stolze wrote:
Quote:
usenet@kikobu.com wrote:
>
Quote:
>Hi.
>>
>I would like to retrieve all records from a table except these where
>the (a, b) combination has one of a series of specific values. For
>example, in MySQL I can given the table:
>>
>a b
>1 2
>1 3
>3 4
>>
>Do:
>>
>SELECT a, b
>FROM tbl
>WHERE (a, b) != (1,2) AND (a, b) != (3,4)
>>
>And get result:
>>
>1 3
>>
>Whats the DB2 equivalent?
>
DB2 only supports the equality comparison:
http://publib.boulder.ibm.com/infoce...n/r0000747.htm
>
So you'll have to simply transform the above predicate.
>
NOT ( (a, b) = (1, 2) OR (a, b) = (3, 4) )
>
or use the [NOT] IN predicate
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
  #4  
Old August 11th, 2006, 02:05 PM
Brian Tkatch
Guest
 
Posts: n/a
Default Re: "... WHERE (a, b) != (1,2) AND (a,b) != (1,3) ..."

usenet@kikobu.com wrote:
Quote:
Hi.
>
I would like to retrieve all records from a table except these where
the (a, b) combination has one of a series of specific values. For
example, in MySQL I can given the table:
>
a b
1 2
1 3
3 4
>
Do:
>
SELECT a, b
FROM tbl
WHERE (a, b) != (1,2) AND (a, b) != (3,4)
>
And get result:
>
1 3
>
Whats the DB2 equivalent?
>
Thanks.
>
Morten
The DB2 equivalent, actually, the SQL equivalent, is to use IN.

In DB2 style (because of the VALUES clause) it becomes:

SELECT a, b
FROM tbl
WHERE (a, b) NOT IN (VALUES(1,2), (3,4))

B.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles