ballhogjoni Posted March 23, 2009 Share Posted March 23, 2009 Can you do this? WHERE column_name IN (1-100) Quote Link to comment https://forums.phpfreaks.com/topic/150728-solved-can-you-specify-a-range-in-a-where-in/ Share on other sites More sharing options...
trq Posted March 23, 2009 Share Posted March 23, 2009 Using some simple php, yes. $range = range(1,100); $sql = "SELECT foo FROM tbl WHERE fld IN ('" . implode("','", $range) . "')"; Quote Link to comment https://forums.phpfreaks.com/topic/150728-solved-can-you-specify-a-range-in-a-where-in/#findComment-791866 Share on other sites More sharing options...
JonnoTheDev Posted March 23, 2009 Share Posted March 23, 2009 Not that I am aware of unless you created a string from an array in PHP to pass into the IN operator. Normal operation would be WHERE column_name >= 1 AND column_name <= 100 http://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html Quote Link to comment https://forums.phpfreaks.com/topic/150728-solved-can-you-specify-a-range-in-a-where-in/#findComment-791868 Share on other sites More sharing options...
fenway Posted March 27, 2009 Share Posted March 27, 2009 Using some simple php, yes. $range = range(1,100); $sql = "SELECT foo FROM tbl WHERE fld IN ('" . implode("','", $range) . "')"; Yes, but why not use BETWEEN? Quote Link to comment https://forums.phpfreaks.com/topic/150728-solved-can-you-specify-a-range-in-a-where-in/#findComment-795284 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.