lordvader Posted June 26, 2008 Share Posted June 26, 2008 Sometimes in practice I see SELECT * FROM TABLE WHERE 1=1 What's that 1=1 for? thx Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 Just to evaluate to true. Quote Link to comment Share on other sites More sharing options...
lordvader Posted June 27, 2008 Author Share Posted June 27, 2008 So why bother? Why not just SELECT * FROM TABLE? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 A number of reasons -- sometimes, where clauses are added to on-the-fly, so have 1=1 means it's easy to say "+= AND .... " (though joining an array is cleaner); I always like to have a WHERE clause so that it doesn't look like an accident. Quote Link to comment Share on other sites More sharing options...
lordvader Posted June 27, 2008 Author Share Posted June 27, 2008 Thanks fen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.