I have a 'user_id' column in my 'user' table. All users with user ids from 1900 up to 2500 experienced a glitch when registering. When a user logs in, if their user id is within that range, i let them click a button to change something. The way I did this was just simply hard code the values in with php:
PHP Code:
if ( $user_id >= 1900 && $user_id <= 2500 ) { // if within glitched user id range
/* show button */
}
This works fine but I'm just curious if there would be a way to do something like this using just sql. Like...if I wanted to check to see if something is in a column in between row 30 and row 100 of my table. I can picture situations where this might be useful.
That wasn't what I was talking about but no worries. There would really never be a need to do what I was talking about.
After posting my question I realized that it was stupid and actually made no sense. I guess a hectic morning at work along with being sick was clouding my mind.
I did learn someting though I knew nothing about BETWEEN and now I do.
You could use BETWEEN which is more convenient and less typing, but it gets processed as OR when your query runs. You could also just move the if to your WHERE clause in MySQL. Probably wouldn't do anything in this case 'cause you're only getting one record, but in a big table when you only want some data, evaluating that in the database instead of the web server will make your code run faster.
if it's just rown numbers you wanted, you could always use the limit/offest.. that way your always going to select X rows from offset Y... there are uses I'm sure