File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes What statement could you use in the WHERE clause to select all the rows in a table where no price is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What statement could you use in the WHERE clause to select all the rows in a table where no price is" Watch "What statement could you use in the WHERE clause to select all the rows in a table where no price is" New topic
Author

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

Joined: Nov 25, 2008
Posts: 1199


I answered 1 answer, but it is wrong.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

[edited]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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

Joined: Nov 25, 2008
Posts: 1199
this question come in local exam.
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

@Aruna your answer is correct.


S.D. MADHAN
Not many get the right opportunity !
Abhishek Ralhan
Ranch Hand

Joined: Aug 01, 2010
Posts: 40

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.


-Abhishek
I came to this world on a Learner's License
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1772
    
  14



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).

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What statement could you use in the WHERE clause to select all the rows in a table where no price is