Hy,
I'm new to mysql joins ... and i can't figure the logic now ...
I have a table : attributes
(1, 'display')
(2, 'processor')
(3, 'size')
and another table : products
(id, product_id, group, name, link_id)
(1, '12', display, Color, 0)
(2, '12', display, Resolution, 0)
(3, '12', display, Size, 0)
(4, '13', display, Color, 1) - this is the link_id (it holds the id of the same group of another product)
(5, '13', processor, 'Cache', 0)
... etc
So i want to build an ajax that when admin select the product category the script verify if it has a liked group to restrict adding fields to that group .
So basically ... i need to have a query to return :
(2, processor)
(3, size)
when user wants to alter attribut开发者_如何学Goes for product with id = 13 (because display
group is used as a link)
select a.id, a.name
from products p
left join attributes a on a.name=p.name
where p.product_id=X;
In this case X would be 13
精彩评论