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 Link to comment https://forums.phpfreaks.com/topic/112104-solved-whats-where-11-for/ Share on other sites More sharing options...
fenway Posted June 27, 2008 Share Posted June 27, 2008 Just to evaluate to true. Link to comment https://forums.phpfreaks.com/topic/112104-solved-whats-where-11-for/#findComment-575596 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? Link to comment https://forums.phpfreaks.com/topic/112104-solved-whats-where-11-for/#findComment-575612 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. Link to comment https://forums.phpfreaks.com/topic/112104-solved-whats-where-11-for/#findComment-575937 Share on other sites More sharing options...
lordvader Posted June 27, 2008 Author Share Posted June 27, 2008 Thanks fen Link to comment https://forums.phpfreaks.com/topic/112104-solved-whats-where-11-for/#findComment-576182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.