Jump to content

Recommended Posts

SELECT * 
FROM s_products AS p
INNER JOIN s_products_categories AS pc ON pc.product_id = p.id
AND pc.category_id =  '216'
WHERE p.brand_id =  '5881'

данный запрос делает выборку в базе по айдишнику бренда и категории. А мне хотелось бы вытащить еще цену для товара. (таблица s_variants - поле price)

Link to post
Share on other sites
  • 2 weeks later...

SELECT * , (select price from s_variants where s_products.id=s_variants.produst_id) as pprise 
FROM s_variants as v, s_products AS p
INNER JOIN s_products_categories AS pc ON pc.product_id = p.id
AND pc.category_id = '216'
WHERE p.brand_id = '5881'

SELECT * , v.price 
FROM s_variants as v, s_products AS p
INNER JOIN s_products_categories AS pc ON pc.product_id = p.id
and  s_variants.product_id=s_products.id 
AND pc.category_id = '216' 
WHERE p.brand_id = '5881'
 
Link to post
Share on other sites

SELECT *

FROM s_variants as v, s_products AS p

INNER JOIN s_products_categories AS pc ON pc.product_id = p.id

WHERE p.brand_id= '5881' and v.product_id=p.id

AND pc.category_id = '216'

 

не работает к сожалению. Запрос выполняется без ошибок, но выдает пустоту

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...