2

I have two tables and I want to use a query to place in the "SUPPLIERS_ORDERS" table those products from the "PRODUCTS" table that have the value "1" in the "top" column. Doing it manually I think is wrong, can it be automated?

                                                     PRODUCTS
+----+-------------+------------------------+-------+-------------------+----------+-------------+--------+-----+
| id | id_category | name                   | price | description       | id_photo | id_supplier | amount | top |
+----+-------------+------------------------+-------+-------------------+----------+-------------+--------+-----+
|  1 |           1 | Xiaomi Redmi Note 8t   |   170 | ...               |        1 |           1 |     19 |  0  |
|  2 |           1 | Xiaomi Redmi Note 9    |   372 | ...               |        2 |           1 |     14 |  0  |
|  3 |           3 | Tesla Model S          | 51322 | ...               |        3 |           2 |     10 |  1  |
|  4 |           2 | Xiaomi Mi Notebook Pro |  1388 | ...               |        4 |           1 |     11 |  0  |
|  5 |           3 | Tesla Model X Plaid    | 61494 | ...               |        5 |           2 |     14 |  1  |
|  6 |           1 | Iphone 13 Pro          |  1287 | ...               |        6 |           5 |    100 |  1  |
|  7 |           4 | Haper PC               |  2946 | ...               |        7 |           6 |     10 |  0  |
|  8 |           2 | Asus Rog Strix 7       |  1795 | ...               |        8 |           4 |     13 |  1  |
|  9 |           2 | Acer Aspire 7          |  1083 | ...               |        9 |           3 |      7 |  1  |
| 10 |           4 | Qube I5                |  1321 | ...               |       10 |           7 |      3 |  0  |
+----+-------------+------------------------+-------+-------------------+----------+-------------+--------+-----+

                   SUPPLIERS_ORDERS
+----+-------------+------------+------------+--------+
| id | id_supplier | id_product | date       | amount |
+----+-------------+------------+------------+--------+
arnold
  • 177
  • 7

0 Answers0