If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > multiple query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-05, 18:07
localhost localhost is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
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?
Reply With Quote
  #2 (permalink)  
Old 01-15-05, 19:50
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
select aplist.* 
     , othertable.username
  from aplist 
inner
  join othertable
    on aplist.userid
     = othertable.primarykey  
 where aplist.mac = 'something'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-18-05, 00:38
localhost localhost is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
works like a charm, thanks for your help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On