Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2007, 11:36 PM
##2912## ##2912## is offline
Junior Member
 
Join Date: Apr 2007
Posts: 12
Default Where condition "0=1" means what

What does the Where condition in the following SQL Query means:
Select * from employeetable where 0=1;
Reply With Quote
  #2  
Old 06-06-2007, 11:39 PM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default RE: Where condition

It would select all columns from that table from the row that has a column named "0" matching the value of "1".

Normally where you have 0, it would be something like username, password, address etc etc.

http://www.chessoscorner.com
Reply With Quote
  #3  
Old 06-06-2007, 11:57 PM
##2912## ##2912## is offline
Junior Member
 
Join Date: Apr 2007
Posts: 12
Default RE: Where condition

Hi,
i did not get u...
my table does not have any column named "0" and the query returns all the columns names with no rows...


thanks
Reply With Quote
  #4  
Old 06-07-2007, 12:08 AM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default RE: Where condition

I see, it must be treated specially.

Is there anything in particular you are trying to do?

http://www.chessoscorner.com
Reply With Quote
  #5  
Old 06-07-2007, 12:17 AM
davidj davidj is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,900
Default RE: Where condition

Where 0=1 ?

0 Represents the field name. This is highly unusual.

Usually field names are not represented by numbers.
Reply With Quote
  #6  
Old 06-07-2007, 12:24 AM
Chesso Chesso is offline
Senior Member
 
Join Date: May 2004
Location: Sydney, Australia
Posts: 1,199
Default RE: Where condition

Yeah you would normally....

SELECT * FROM mytable WHERE id=N

N being a number, ID being an auto_increment value, like a table of members for a website (each one having a unique ID), or WHERE username=name

Or if you only need a couple of columns, not all of them, specify them instead of using *, like:

SELECT username, password, email FROM mytable WHERE id=N

http://www.chessoscorner.com
Reply With Quote
  #7  
Old 06-07-2007, 12:31 AM
davidj davidj is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,900
Default RE: Where condition

if 0 is not a field then the result will always return
zero records. I have never heard of a field name being
named a number, I dont even know if this is possible?
Reply With Quote
  #8  
Old 06-07-2007, 05:44 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: Where condition

Essentially, this is used to query the structure of the
table as it will never return any rows.


MrBaseball34
Hook'Em Horns!

2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:10 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.