Jump to content

[SOLVED] select * from db where id between 0 and no maximum < how can you specify no max?


Recommended Posts

my db holds the size of something in metres. I know the size won't realistically be over 10,000, but I want to include any possible number.

 

At the moment, I have "where id between 0 and 9999999999999"  ;D

 

Surely there is a better way to do this?

 

Thanks.

sorry, I should have explained it a little better.

 

the query is generated from form results, and sometimes it will be "between 0 and 10" etc

 

one of the options is "No Maximum" and its value is currently set to 999999999999

 

 

 

 

So when user chooses a maximum value do a query:

 

SELECT * FROM table WHERE ID > $min AND ID < $max;

 

And if he/she chooses 'no maximum' just omit 'AND ID < max' part

 

Alternatively, if you selected ID to be UNSIGNED INTEGER, you might use 4294967295 as a maximum value.

http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.