By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,237 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,237 IT Pros & Developers. It's quick & easy.

"... WHERE (a, b) != (1,2) AND (a,b) != (1,3) ..."

P: n/a

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

Aug 11 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
us****@kikobu.com wrote:
>
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
Aug 11 '06 #2

P: n/a
us****@kikobu.com wrote:
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.

Aug 11 '06 #3

P: n/a
Knut Stolze wrote:
us****@kikobu.com wrote:
>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/
Aug 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.