Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

Commonmark migration
Source Link

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR (2ドル IS NULL AND season_id IS NULL))
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR (2ドル IS NULL AND season_id IS NULL))
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR (2ドル IS NULL AND season_id IS NULL))
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;
added 17 characters in body
Source Link
Lukasz Szozda
  • 181.6k
  • 26
  • 278
  • 326

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR (2ドル IS NULL AND season_id IS NULL))
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR season_id IS NULL)
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR (2ドル IS NULL AND season_id IS NULL))
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;
Source Link
Lukasz Szozda
  • 181.6k
  • 26
  • 278
  • 326

From Comparison Functions and Operators:

Do not write expression = NULL because NULL is not "equal to" NULL. (The null value represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications might expect that expression = NULL returns true if expression evaluates to the null value. It is highly recommended that these applications be modified to comply with the SQL standard. However, if that cannot be done the transform_null_equals configuration variable is available. If it is enabled, PostgreSQL will convert x = NULL clauses to x IS NULL.

and:

19.13.2. Platform and Client Compatibility

transform_null_equals (boolean)

When on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct SQL-spec-compliant behavior of expr = NULL is to always return null (unknown). Therefore this parameter defaults to off.


You could rewrite your query:

SELECT * 
FROM seasons 
WHERE user_id = 1ドル 
 AND (season_id = 2ドル OR season_id IS NULL)
-- ORDER BY ... --LIMIT without sorting could be dangerous 
 -- you should explicitly specify sorting
LIMIT 1;
lang-sql

AltStyle によって変換されたページ (->オリジナル) /