Click here to Skip to main content
16,004,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

select * from table where 3 > 2 what will return this query? anyone explain this query??
Posted

Following the WHERE keyword is a logical expression, also known as a predicate.

The predicate evaluates to a SQL logical value -- true, false or unknown. The most basic predicate is a comparison:

color = 'Red'

This predicate returns:
true -- if the color column contains the string value -- 'Red',
false -- if the color column contains another string value (not 'Red'), or
unknown -- if the color column contains null.

In your query the predicate 3 > 2 is always true.. As no other condition is present the query will fetch all the rows from the table. Hope this explains...
 
Share this answer
 
3 > 2 is always true. It will display all the rows when you execute. likewise 5 > 2 , 6 > 1 etc.
But if you try with 2 > 3, you will not get any results as it is always false.
As you mentioned only one conditional clause .

Thank you
 
Share this answer
 
v2
Where is used to filter the from all the data.
Here the condition 3>2 always true.It means condition is always true & no other conditions are there to filter.

*So, It works similar as Select * from TableName.

-- Returns All records --
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900