A
A
alex4answ2019-04-03 20:47:39
Yii
alex4answ, 2019-04-03 20:47:39

How to properly join for several elements from the total selection?

Good afternoon, there are 2 tables:
1. Goods
2. Delivery
The whole problem is that the goods are of different types, some have delivery, others do not, for example, refrigerators can have delivery, but a flamethrower does not (you cannot add delivery systemically, and not just that there is simply no information in the table)
How to get all the goods + delivery correctly (to those who have delivery allowed by the type of goods)
You can do a regular JOIN, but I have 40 products, only 3 can have delivery, it will turn out like this , that for 37 products a table will be searched, although there is no delivery for them and cannot be.
How to do it all right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-04-03
@dimoff66

JOIN ON Tovary.hasDelivery = 1 AND Tovary.id = Dostavka.tovar_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question