• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What statement could you use in the WHERE clause to select all the rows in a table where no price is

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I answered 1 answer, but it is wrong.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[edited]
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should tell us what you think, then we'll tell you whether we agree. Also please say where the question comes from, to avoid copyright and similar problems.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this question come in local exam.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Aruna your answer is correct.
 
Abhishek Ralhan
Ranch Hand
Posts: 40
Chrome Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also try to use all these combinations.
Actually it depends upon the term "where no price is defined". Whatever this term means, the answer lies in that meaning only.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Also, remember that NULL is not equal to anything (even NULL) so it always fails any comparison with a value. So a NULL value in your table column will return false for any comparisons, except when you use the operators "IS NULL" (returns true if value is NULL) or "IS NOT NULL" (returns true if value is anything except NULL).

Depending on your database, you can also use the NVL() function to handle NULL values in your comparisons etc. NVL(input, output) means that if the input value IS NULL, then the function should return the output value instead, otherwise it just returns the input value. For example:

WHERE NVL(price, 0) = 0

This will return the rows where price is a non-NULL value and equal to 0, or where price is NULL (because the NVL function converts the NULLs to 0 before comparing them).

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic