I
I
Ivan2021-10-15 01:04:21
MySQL
Ivan, 2021-10-15 01:04:21

How to correctly compose this mysql query using Laravel constructor?

Good afternoon.

There are three tables: one with products, one with countries, and one with prices for those products.

With goods products
With countries countries
With prices prices

In prices, the price is indicated, and there are also two columns product_id and country_id - because. for each country, different price. For this, a separate table has been made.

There is also an input variable STRING - {alias_product/country_id}. Example: vk/2. If there are several, then - vk/2|tg/1, etc.
This variable is a list of exceptions (more on that later). In addition to this line, I also have a variable with a number ($amount) by which I need to lower/increase the price.

I need to change the price for all products to $amount in the prices table, but I can't change the exception products.
I want to do everything in one request on laravel constructor. Understood for a long time in the documentation, it does not work in any way.

The only thing I can do is to exclude from the request the price of all products with N alias and N shit.
Those. specified vk/2|tg/1, it will remove vk in country 1, vk in country 2, tg in country 1, tg in country 2.
And should not touch only vk in the 2nd country and tg in the 1st country.

I will be very grateful.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question