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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logic in WHERE Clause

Status
Not open for further replies.

nkimlinger

IS-IT--Management
Jul 24, 2003
2
US
I am customizing a third party application, using MS Access Project on SQL 7.0. I am working on a bound Access form wiht the data source of: "SELECT * FROM tableName WHERE 1 = 2". This returns a blank row, which allows the user to enter a new record into the bound table. When you remove the WHERE clause, it does not allow a new record to be entered, even with the form properties set to Allow Additions and Data Entry = Yes.

What is the logic behind the 'WHERE 1 = 2' clause? I am unfamiliar with this in a SQL statement. Can anyone explain this to me?

Thanks.

 
Sounds like the orignal programmer did this as a workaround. Where 1=2 is used when you don't want any records returned as it is an impossible condition to meet.
 
the 2=1 is simply pulling an empty record set.
IT helps you reuse forms. The same form can be used for a new record or to edit a record.

When you have existing data, it is pulled from the database.
Where none exists, this type of query makes an empty record set with a set of empty strings. Think of it as a way of making a new record like it's an existing record.

I use these type of records all the time with my web apps. Its saves alot of conditional logic- making the application think it's a simple edit.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top