tags:

views:

49

answers:

2

Hi, I have a database situation where I'd like to get a user profile row by a user age range.

this is my db:

table_users
username     age     email                     url
pippo        15      [email protected]       http://example.com
pluto        33      [email protected]       http://example.com
mikey        78      [email protected]       http://example.com


table_profiles
p_name       start_age_range      stop_age_range
young        10                   29
adult        30                   69
old          70                   inf

I use MySQL and PHP but I don't know if there is some specific tacnique to do this and of course if it's possible.

# so something like:
SELECT *
FROM table_profiles AS profiles
INNER JOIN table_users AS users
# can I do something like this?
ON users.age IS BETWEEN profiles.start_age_range AND profiles.stop_age_range
A: 

What about

    SELECT *
    FROM table_profiles AS profiles
    Where 
 users.age >= profiles.start_age_range AND users.age <=profiles.stop_age_range
Taz
'INNER JOIN <table alias> ON <boolean>' isn't legal SQL for any database.
Craig Trader
Removed Thanks.
Taz
+1  A: 
Select
  *
From
  table_profiles As profiles,
  table_users As users
Where
  users.age Between profiles.start_age_rage And profiles.stop_age_range
thisMayhem
thank you, I thought it was something like BETWEEN clause
Vittorio Vittori
You're very welcomed (:
thisMayhem