Compare id in two tables and return sql promo value

Asked

Viewed 22 times

0

Hello! In my product table and in the promotion table are idcategory, I have my product with a certain category and when I find the same idcategory in the promotion table and this is with active status, return the value of the promotion discount (promotion table). It is possible to do in a query?

1 answer

1


Good afternoon, would look something like this:

SELECT DESCONTO, IDPRODUTO FROM PRODUTOS P
INNER JOIN PROMOCAO PR ON PR.IDCATEGORIA = P.IDCATEGORIA
WHERE P.IDPRODUTO = X AND PR.ATIVO = 1;

PR.ACTIVE = 1 I DON’T KNOW WHAT VC SAVES AS TRUE OR FALSE BUT NORMALLY IS 0 FALSE AND 1 ACTIVE.

  • Perfect, it worked! Thank you so much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.