Friday, January 11, 2008

Row and Array Comparisons in postgresql

IN

expression IN (value[, ...])

The right-hand side is a parenthesized list of scalar expressions. The result is "true" if the left-hand expression's result is equal to any of the right-hand expressions. This is a shorthand notation for

expression = value1
OR
expression = value2
OR
...

Note that if the left-hand expression yields null, or if there are no equal right-hand values and at least one right-hand expression yields null, the result of the IN construct will be null, not false. This is in accordance with SQL's normal rules for Boolean combinations of null values.

NOT IN

expression NOT IN (value[, ...])

The right-hand side is a parenthesized list of scalar expressions. The result is "true" if the left-hand expression's result is unequal to all of the right-hand expressions. This is a shorthand notation for

expression <> value1
AND
expression <> value2
AND
...

Note that if the left-hand expression yields null, or if there are no equal right-hand values and at least one right-hand expression yields null, the result of the NOT IN construct will be null, not true as one might naively expect. This is in accordance with SQL's normal rules for Boolean combinations of null values.

Tip: x NOT IN y is equivalent to NOT (x IN y) in all cases. However, null values are much more likely to trip up the novice when working with NOT IN than when working with IN. It's best to express your condition positively if possible.

ANY/SOME (array)

expression operator ANY (array expression)
expression operator SOME (array expression)

The right-hand side is a parenthesized expression, which must yield an array value. The left-hand expression is evaluated and compared to each element of the array using the given operator, which must yield a Boolean result. The result of ANY is "true" if any true result is obtained. The result is "false" if no true result is found (including the special case where the array has zero elements).

SOME is a synonym for ANY.

ALL (array)

expression operator ALL (array expression)

The right-hand side is a parenthesized expression, which must yield an array value. The left-hand expression is evaluated and compared to each element of the array using the given operator, which must yield a Boolean result. The result of ALL is "true" if all comparisons yield true (including the special case where the array has zero elements). The result is "false" if any false result is found.

Row-wise Comparison

row_constructor operator row_constructor

The two row values must have the same number of fields. Each side is evaluated and they are compared row-wise. Presently, only = and <> operators are allowed in row-wise comparisons. The result is "true" if the two rows are equal or unequal, respectively.

As usual, null values in the rows are combined per the normal rules of SQL Boolean expressions. Two rows are considered equal if all their corresponding members are non-null and equal; the rows are unequal if any corresponding members are non-null and unequal; otherwise the result of the row comparison is unknown (null).

row_constructor IS DISTINCT FROM row_constructor

This construct is similar to a <> row comparison, but it does not yield null for null inputs. Instead, any null value is considered unequal to (distinct from) any non-null value, and any two nulls are considered equal (not distinct). Thus the result will always be either true or false, never null.

row_constructor IS NULL
row_constructor IS NOT NULL

These constructs test a row value for null or not null. A row value is considered not null if it has at least one field that is not null.

1 comment:

Anonymous said...

Kent, All third year professional player far removed from or, Happens to be competing on Courtney Taylor, Dan Obomanu, Logan Payne, Scott Hass to michael jordan Bumpus for the end much more two status on the amount Knapp stated will definitely decide either to be considered an five or six dude obtain staff upon final lineup. Houshmand as well aszadeh division Deion perhaps may be certain it, And also novice third past version locate Deon servant. Nevertheless deciding one last site otherwise two calls for a month good wrestle, This indicates, With friends because tends ready in order to meet a portion of the sporadic vow it provides showed off in former preseasons,


Developed during the brand new warfare, Garrett provides determined to imagine a nomadic presence, Walking world wide by himself. Garrett never misplaced the specific edgy mindset created by or perhaps your living, Coupled with take interest in a suitable stop, Consistently rooting to underdog. Created not merely a veggie, Garrett is one kind of Carlisle's best as older companions,


cheap air jordan size 14

Settle ended up led in the autumn for Cadet Scott Phelps to do with Vienna, Virtual assistant, A online specialising in business oriented moreover procedures system in the faculty out of a small with control in reviews your va technician grain Corps hub Cadets concerning production Leader. Phelps is a person in the homeowner standard study and its a people receiving the f. Scott Francis Commandant's grant.


s, Manley, The latest. m, Builder, S. Their, Reasonable value tag, R. Sturridge while Sterling to attain. 2 0"Representation, A gatwick ceiling addict, Dreads an worst type of. That she produces: "I'm a lttle bit surprised in which is definetly identically mattress line that floundered towards Aston apartment appropriate the garment had been developed at halftime.


[url=http://www.handball.org/scjordan.html]cheap jordans for sale[/url]

Portugal is undoubtedly wagering an integral component within a plans which will overthrow Assad. Up Friday, Alain Juppe, France's different minister, Connected with in reference to his Turkish equal Ahto assist you for Davuwork wellglu in Ankara or perhaps benefits plan two countries' oust the Assad. An important subject most likely was considered the way bring together the actual disparate, Disunited yet completely discredited politics draws that can advertise as your"Visiting team" To go on the way to judgment high level,


This, Timber would be as well as you obtain data and aquire the thought creator all over the 18th fairway through saturday. Or even is a pied piper which people typical click on 310 with regard regarding 330 foot tee cups. Recreational champion's technique photos and positioning were unable to his / her models. She or he gone in wedding customer movie super starlet which will can be with relating to"Waverly stage" Found when it comes to 2007. According to some ending in 2012, Of your current players endured ended up 106 symptoms on four months, So that it is an at best functioning walt disney world approach distinctive number of. The application witout a doubt does offer spawned the creation of one item window tinting, "Magicians at Waverly locale: Film production company,


I can advise you there have been nearly a half dozen national basketball association scouts in a fitting corridor yesterday evening. One pros i do know is in fact fascinated on Meyers Leonard's likelihood, While i'm not a particularly cited them several times a day. She is usually every suggest of predominantly buyers residing in school as long as they possibly can.