Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:54:18+00:00 2026-05-25T17:54:18+00:00

I am trying to check for people in a certain age range. I have

  • 0

I am trying to check for people in a certain age range. I have two ComboBoxes, minagecombobox and maxagecombobox, with values between 1 and 120.

I want to get the people whose age is between these two values (suppose for example I want to filter out the people aged between 18 and 24).

This is the Member table structure:

     member_id 
     member_firstname 
     member_dob(datatype is string) (values like 1987-09-08,1976-09-08,.....)

i am using mysql as my database…..

**Modified query** 


             SELECT members.member_Id,
                   members.member_Lastname as 'Last Name',
                   members.member_Firstname as 'First Name',
                   members.member_Postcode as 'Post Code',
                   members.member_Reference as Reference,
                   members.member_CardNum as 'Card Number',
                   members.member_IsBiometric as Biometric,
                   members.member_DOB as DoB,
                   mshiptypes.mshipType_Name as Membership,
                   mshipstatustypes.mshipStatusType_Name as Status,
                   membertomships.memberToMship_EndDate as Expiry
                     FROM members
    INNER JOIN membertomships ON membertomships.member_Id = members.member_Id
     INNER JOIN mshipoptions ON mshipoptions.mshipOption_Id = membertomships.mshipOption_Id
    INNER JOIN mshiptypes ON mshiptypes.mshipType_Id = mshipoptions.mshipType_Id
    INNER JOIN mshipstatustypes ON mshipStatusTypes.mshipStatusType_Id = membertomships.mshipStatusType_Id
    WHERE memberToMship_EndDate BETWEEN '2011-09-24' AND '2011-09-30'
    AND members.member_active LIKE 'y%'
    AND (YEAR(CURDATE(members.member_Dob))-YEAR()) - (RIGHT(CURDATE(),5)< RIGHT(member_Dob,5)) BETWEEN '21' AND '102'
    ORDER BY members.member_Lastname

got an error like this…..

     Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'member_Dob))-YEAR()) - (RIGHT(CURDATE(),5)< RIGHT(member_Dob,5)) BETWEEN '21' AN' at line 19
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:54:19+00:00Added an answer on May 25, 2026 at 5:54 pm

    Try this:

    SELECT * FROM MEMBER
    WHERE (YEAR(CURDATE())-YEAR(member_dob)) - (RIGHT(CURDATE(),5)<RIGHT(member_dob,5)) 
    BETWEEN 18 AND 24
    

    The WHERE clause has the age calculation formula. Get the number of years by subtracting the year of birth from current year and then further subtract 1 if one current day and month is less than the day and month of DOB. In case, you get a datatype mismatch error, use STR_TO_DATE(member_dob, '%Y-%M-%d') to convert the string DOB to DATETIME DOB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to check for people in a certain range - let minage
I am trying to check a series of buttons to see if they have
I'm always writing tests to check my controller restricts people from certain actions depending
I have a video kiosk setup in my lobby, it lets people check in
I'm trying to check whether $('select option:selected').val(); contains certain words and if so, redirect
I want that people trying to subscribe on my website to enter a nickname
I am trying to debug some Tree View code, and I want to check
I think I have found a bug in UIScrollView, but I want to check
I am trying to override equals method in Java. I have a class People
I'm trying to check if a file exists. If I use this: NSData *data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.