ballhogjoni Posted March 23, 2009 Share Posted March 23, 2009 Can you do this? WHERE column_name IN (1-100) 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) . "')"; 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 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? 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
Archived
This topic is now archived and is closed to further replies.