everythingandtwo Posted July 30, 2003 Share Posted July 30, 2003 If I\'m wanting to select records from a database between two numbers, what would be the best way to write the SQL statement for it? Here\'s what I have currently, but for some reason it doesn\'t work... SELECT * FROM guestbook_main WHERE entry_num >= " . $min . " and entry_num <= " . $max . " ORDER BY entry_num DESC; This doesn\'t return anything, but if I take off the \"and entry_num <= $max\" part of it, it will return all of the entries. I tried using BETWEEN but it didn\'t work either. Can anyone help me out? Thanks, Brad[/code] Quote Link to comment https://forums.phpfreaks.com/topic/799-need-help-with-a-select-statement/ Share on other sites More sharing options...
shivabharat Posted July 30, 2003 Share Posted July 30, 2003 Try this query SELECT * FROM guestbook_main WHERE entry_num between \'$min\' and \'$max\' ORDER BY entry_num DESC Quote Link to comment https://forums.phpfreaks.com/topic/799-need-help-with-a-select-statement/#findComment-2634 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.