Ceci est ma table "produit" WHERE sku RLIKE 'IP-205-1067-16' or sku IN ('205-d-SC55G','205-d-RC099G','205-d-SC45G','205-d-RC099G')
:Joignez-vous à des tables quand une colonne a un préfixe
+---------------------------+---------+-----------------------+-----------------------+-------------------------+----------------------------+
| sku | price_1 | full_color_imprint_id | embroidery_imprint_id | screen_print_imprint_id | laser_engraving_imprint_id |
+---------------------------+---------+-----------------------+-----------------------+-------------------------+----------------------------+
| IP-205-1067-16 | 1.55556 | NULL | NULL | 63276 | 32539 |
| IP-205-1067-16-39423495 | 1.55556 | NULL | NULL | 63276 | 32539 |
| IP-205-1067-16-1272347 | 1.55556 | NULL | NULL | 63276 | 32539 |
| IP-205-1067-16-56185 | 1.55556 | NULL | NULL | 63276 | 32539 |
| IP-205-1067-16-1706399150 | 1.55556 | NULL | NULL | 63276 | 32539 |
| 205-d-SC45G | 45 | NULL | NULL | NULL | NULL |
| 205-d-SC55G | 55 | NULL | NULL | NULL | NULL |
| 205-d-RC059G | 0.59 | NULL | NULL | NULL | NULL |
| 205-d-RC099G | 0.99 | NULL | NULL | NULL | NULL |
+---------------------------+---------+-----------------------+-----------------------+-------------------------+----------------------------+
Ceci est ma table "imprint_locations" WHERE imprint_method_id IN (63276,32539)
:
+--------+-------------------+------------+-------------+--------------+
| id | imprint_method_id | name | setup_sku | running_sku |
+--------+-------------------+------------+-------------+--------------+
| 809128 | 32539 | Body Right | 205-d-SC45G | 205-d-RC059G |
| 809129 | 32539 | Body Left | 205-d-SC45G | 205-d-RC059G |
| 808288 | 63276 | Body Right | 205-d-SC55G | 205-d-RC099G |
| 808289 | 63276 | Body Left | 205-d-SC55G | 205-d-RC099G
+--------+-------------------+------------+-------------+--------------+
Ceci est le résultat final I » m essayant d'atteindre:
+---------------------------+-----------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------+----------------------------------------------+------------------------------------------------+
| sku | embroidery_imprint_id_setup_sku_price_1 | embroidery_imprint_id_running_sku_price_1 | screen_print_imprint_id_setup_sku_price_1 | screen_print_imprint_id_running_sku_price_1 | laser_engraving_imprint_id_setup_sku_price_1 | laser_engraving_imprint_id_running_sku_price_1 |
+---------------------------+-----------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------+----------------------------------------------+------------------------------------------------+
| IP-205-1067-16 | NULL | NULL | 55 | 0.99 | 45 | 0.59 |
| IP-205-1067-16-39423495 | NULL | NULL | 55 | 0.99 | 45 | 0.59 |
| IP-205-1067-16-1272347 | NULL | NULL | 55 | 0.99 | 45 | 0.59 |
| IP-205-1067-16-56185 | NULL | NULL | 55 | 0.99 | 45 | 0.59 |
| IP-205-1067-16-1706399150 | NULL | NULL | 55 | 0.99 | 45 | 0.59 |
+---------------------------+-----------------------------------------+-------------------------------------------+-------------------------------------------+---------------------------------------------+----------------------------------------------+------------------------------------------------+
Vous pouvez voir que la table de produit a screen_print_im print_id qui correspond à l'attribut imprint_method_id dans la table imprint_locations.
'WHERE imprint_locations.setup_sku = CONCAT ('setup_sku_', product.sku)' – Barmar
Vous êtes censé essayer de ** écrire le code vous-même **. Après [faire plus de recherche] (https://meta.stackoverflow.com/q/261592/1011527) si vous avez un problème ** poster ce que vous avez essayé ** avec une ** explication claire de ce qui n'est pas working ** et fournissent [un exemple minimal, complet et vérifiable] (http://stackoverflow.com/help/mcve). Lisez [Comment poser une bonne question] (http://stackoverflow.com/help/how-to-ask). Assurez-vous de [faire le tour] (http://stackoverflow.com/tour) et lisez [this] (https://meta.stackoverflow.com/q/347937/1011527). –
Hey Barmar, ABC et setup sku ABC sont fictifs. J'ai un product.sku appelé he-123-h100 et un fichier imprint_locations.setup_sku appelé 924-gee. – Boris