If I want to search record by age like (30 to 35) just like dating script but I will not use in dating site, I have my school website and I just want to display record by age but If I want to display age between 14 to 17 kindly let me know what should I do?
Thanks in advance

Hehe
what school you attend selecting from age range 30 to 35? After all you are still programming for hidden dating site, isn't it?

Why not writing a simple query as for example:

select all_my_dating from mytables where YEAR(CURDATE()-DOB) between 30 and 35;

Hint: Never store age of a person in database, except you are planing kind of provision of work ;)

-- tesu

Thanks for your reply, as I told before I am new and I just want to make school website. I just want to display student record by age 12 to 18. In my database I didn't used Date of birth I use age column.

Aha age columns. That makes the query tremendously simpler:

SELECT all_my_dating FROM mytables WHERE age BETWEEN 30 AND 35;

... BUT: where keeps the DOB file? And will those ages be manually updated in database just before or just after pupil's birthday partys every year?

-- tesu

In simple terms, age is a calculated value, which will change with time. So NEVER store it, calculate it, as shown in the first answer given. Then it will always be the correct age.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.