I have 2 tables, i would to select 2 columns from 2nd table for the different product Type distinctly selected from 1st Table.
table 1 :
idTable1 product_Type product_name
1 AD Product N1
2 AD Product N2
3 AF Product N3
4 AF Product N4
table 2 :
idTable2 typeISO Manufacturer Phone
21 AD Adidas 121212121
22 AF Lacoste 989898989
23 AX Nike 333333333
I would return :
Array :
product_Type Manufacturer Phone
AD Adidas 121212121
AF Lacoste 989898989
i tested this query but returns only one column : product_Type :
SELECT DISTINCT 1stTable.product_Type FROM 1stTable LEFT JOIN 2ndTable ON 1stTable.product_Type = 2ndTable.typeISO
THX
I think that you are looking for exists
:
select t2.*
from table2 t2
where exists (select 1 from table1 t1 where t1.product_type = t2.typeISO)
This gives you all records in table2
whose typeISO
can be found in column product_type
of table1
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.