0

I want to fetch data from the database. I have three tables in my database like: listing_master_residential, listing_master_condo and listing_master_commercial.

There are three tables and there is one primary key Ml_num in all tables. I want to search the data form one table which matches mls number table.

$sql ="SELECT * FROM listing_master_residential ,listing_master_commercial, listing_master_condo WHERE Ml_num=$option";

i want to show only those data to match ml_num in above table

Tomasz Kowalczyk
  • 10,472
  • 6
  • 52
  • 68
avktech
  • 92
  • 1
  • 11
  • possible duplicate of [SQL JOIN and different types of JOINs](http://stackoverflow.com/questions/17946221/sql-join-and-different-types-of-joins) – rack_nilesh Dec 17 '14 at 10:49
  • here i am using cross join but showing an error Column 'Ml_num' in where clause is ambiguous – avktech Dec 17 '14 at 10:55

1 Answers1

0

Try This by using inner join:

SELECT t1.Ml_num,t2.*,t3.Ml_num FROM listing_master_residential t1 
JOIN listing_master_commercial t2 ON t1.Ml_num = 'W2726470' 
JOIN listing_master_condo t3 ON t1.Ml_num = 'W2726470'

I hope it will help you.

Debug Diva
  • 26,058
  • 13
  • 70
  • 123