SELECT ... WHERE dealing with Subquery Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bilibytes
    New Member
    • Jun 2008
    • 128

    #1

    SELECT ... WHERE dealing with Subquery Array

    Hi everyone,

    I am trying to find out how to make a query within an array.

    i make a query where i get from a table named 'other_info', an array with all the user id's resulting from a subquery.

    Code:
    SELECT user_name
    FROM users 
    WHERE users.user_id IN 
    (
              SELECT other_info.user_id, other_info.age 
              FROM other_info 
              WHERE other_info.state = $state
    )
    what i want is to get the all the user_names and ages from the users living particular state.

    where the tables are designed this way:
    table: users
    Code:
    user_id | user_name
    table other_info
    Code:
    user_id | age | state
    what is the right syntax for this query?

    if you have any suggestion, please let me know

    thank you very much

    bilibytes
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Read about how to use JOINs to join your users and other_info tables.

    Comment

    Working...