Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query where condition

Status
Not open for further replies.

geramis

Programmer
Oct 10, 2001
14
IL
Is there any KeyWord that i can use in sql-server,
that when writing the folloing query:
SELECT fldName
FROM tblName
WHERE fldName = <KeyWord>

the result will be all the records?
if does - what is the KeyWord?
 
I'm not sure what you're trying to do; obviously, the simple answer would be to eliminate the WHERE clause.

But I'm sure you have a reason for asking, so:

* if you can control the entire boolean statement, then you could use: [tt]where 1 = 1[/tt]

* if you must use the column name, and the column does not allow NULL values, you could use: [tt]where fldName is not NULL[/tt]
-----------------
Robert Bradley
use coupon code &quot;TEKTIPS&quot; for 15% off at:
 
If you want all the records just do:
Select fldname from tablename. Leave off the where condition.
If you want only specific records from the table then specify a criteria in your where statement:
where fldname = 'John Doe'

Does that answer your question?

Ashley L Rickards
SQL DBA
 

You can also use WHERE fldName=fldName which is more effiecient than WHERE fldName Is Not Null. But as noted the WHERE is not necessary. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
In addition to the ORIGINAL massage i posted:
i'm calling a sproc (from ASP) that contains a query
of the format i've indicated above and contains a condition of the type:

WHERE fldName1 = @param1
AND fldName2 = @param2

! NOTICE that the condition must be &quot;=&quot;
and i was wondering if i can send any parameter that will
cause all records selection
(sending the field name as parameter doesn't work cause the field data type is int and i get a conversion Error)
 
10'x for everyone,

i've solved my problem by sending @param = NULL values for parameters i want to disable from the where codition
and using WHERE fldName = IsNull(@param,fldName)
in the Condition
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top