[thelist] SQL SELECT Question

Bret Daniel BDaniel at Chemnavigator.com
Tue Dec 10 10:21:01 CST 2002


Hi,

I have seen (an used) 'where 1=1' when constructing dynamic SQL
statements... the 1=1 should always return a value based upon the select...

i.e. select * from aTable where 1=1 << AND aValue=X << AND aValue=B etc..

hope this did something for the cause :)

Bret

-----Original Message-----
From: Burhan Khalid [mailto:burhankhalid at members.evolt.org]
Sent: Tuesday, December 10, 2002 7:26 AM
To: thelist at lists.evolt.org
Subject: [thelist] SQL SELECT Question


Hello All,

      Recently I was asked a SQL question from a person new to SQL
      that had me stumped -- because I had never thought of it before.
      The question was, how do you write a select statement so it
      returns only a list of all values in one column. The first thing
      that came to my mind is the "SELECT * FROM [table]", but that
      returns a list of all records, from all columns.

      I then thought that if I gave a conditional that's always true,
      it might work, ie. "SELECT someColumn FROM someTable WHERE 1=1",
      but was told that it didn't work.

      We eventually decided to go with SELECT *, and dump the data
      that we didn't need, but the question has been bothering me for
      a while. Anyone have any clues?


Regards,
--
*---------------*
| Burhan Khalid |
*---------------*---------------------------*
| Email : burhankhalid[at]members.evolt.org |
| Web   : members.evolt.org/burhankhalid    |
*-------------------------------------------*



--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !



More information about the thelist mailing list