select a.m_num,a.filename,a.title,a.price,a.stock
from newboard a , cart b
where a.m_num = b.m_num and a.board_num = ANY(select board_num from cart where m_num = '82');
The result
FIELD1 | FIELD2 | FIELD3 | FIELD4 | FIELD5 |
---|---|---|---|---|
82 | NO1.png | car | 39000 | 1 |
82 | 0 | 0 | ||
82 | NO1.png | car | 39000 | 1 |
82 | 0 | 0 | ||
82 | NO1.png | car | 39000 | 1 |
Why is it repeating?
Since inner join is working as Cartesian Product. To get distinct rows either use distinct keyword after select or use group by.
Example:
select a.m_num,a.filename,a.title,a.price,a.stock
from newboard a , cart b
where a.m_num = b.m_num
and a.board_num = ANY(select board_num from cart where m_num = '82')
group by a.m_num,a.filename,a.title,a.price,a.stock;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments