Results 1 to 3 of 3

Thread: multiple query

  1. #1
    Join Date
    Oct 2003
    Posts
    13

    Unanswered: multiple query

    Hello all,

    I have a php script running a mysql query to populate a table with values.

    One of the values is the userid associated with that row, where the userid is the primary key on another table.

    Is there a way to incorporate something into the query to replace the userid with the corresponding username?

    The tables are in myISAM mode so no foreign keys can be used.

    the query that i am running looks like this :

    select * from aplist where mac="something";

    one of the values it returns is an integer, and i need that integer to be turned into (or added as another value) their username....

    any ideas?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select aplist.* 
         , othertable.username
      from aplist 
    inner
      join othertable
        on aplist.userid
         = othertable.primarykey  
     where aplist.mac = 'something'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Posts
    13
    works like a charm, thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •