Skip to content
Advertisement

Query only doing half of what I want

I have a function that is supposed to delete a product and, with it, delete its stock as well. But it keeps just deleting the stock. SSometimes I change the order of the querys and it shows an error that I can’t delete idproduto because its an FK, so I put the delete stock query first. It deletes the stock and there’s no error, but it doesn’t delete the product.

Database:

TABLE produtos(idproduto, descr) TABLE stock(idstock, idproduto, stock)

Code:

I also tried to put the delete produtos query right under the other, I switched them….

Advertisement

Answer

You can use left join

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement