PDA

View Full Version : [php] mysql_query question



Thinker2501
January 27th, 2005, 02:50 PM
I have a DB with two tables, 'listing' and 'brokers'. I have it returning rows from listing in a loop and displaying them correctly and all, the row is stored in the variable $result. I want to take $result_ar['lastname'] and use it to such the column 'lastname' in 'brokers' and return the row when it finds the match. How would I do that. I've been working on this for a while now with no results.

amitgeorge
January 27th, 2005, 02:56 PM
try relating the tables....

SELECT listing.*, brokers.lastname
FROM listing INNER JOIN brokers ON listing.BROKERID = brokers.ID

Thinker2501
January 27th, 2005, 03:49 PM
could you explain the code? Thanks.

amitgeorge
January 28th, 2005, 04:23 AM
http://www.w3schools.com/sql/sql_join.asp