Hi all , I wish to select all the rows from one table that matches a cell in another table , but when i do it it a get duplicate rows eg i want to select all the rows from T1 that match the word A in table T2 so the result would be a,a,a, or if it was C i would get one C eg +--------+ +--------+ | T1 | |T2 | +--------+ +--------+ |A | |A | |A | |C | |A | | C | |C | | C | What would be the SELECT or the join query to do this ?
You are also going to need a sub-query: SELECT T1.fa FROM T1 INNER JOIN (SELECT DISTINCT T2.fb FROM T2) AS SUB ON T1.fa = SUB.fb; PHP: T1 is the first table, fa is the field in that table whose results you want. T2 is the second table, fb is the field in that table you want to limit results to.