Jump to content

php mysql BETWEEN FUNCTION QUERY??


antonyfal

Recommended Posts

Hi,

Doing a Query SELECT * FROM table WHERE field BETWEEN low_number AND high_number

 

If i have three rows with three numbers: IE: 27, 50, 80.

and i run the query above, it returns a result of:

27 and 50.

 

How can i get it to return a result of:

27,50, and 80.??

 

WHY:

age range search: i want to return an age range of people = and between the age of say: 20 and 70 but i want to include the 20 and 70.

How can i do this?

 

Link to comment
https://forums.phpfreaks.com/topic/253367-php-mysql-between-function-query/
Share on other sites

Unless a person is dead, their age is not a constant number. It changes once a year on their birthday.

 

You need to store the date of birth and then to find age ranges, perform a date comparison that corresponds to the correct birthday date range calculated relative to the current date.

I agree with PFMaBiSmAd, but a BETWEEN query should work fine if you insist on proceeding with what you have. If you read the manual entry, you'll see that the values used in the BETWEEN comparison are inclusive.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.