Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use left join when trying to add new table to update. #65

Open
brittainmark opened this issue Jun 15, 2022 · 2 comments
Open

Cannot use left join when trying to add new table to update. #65

brittainmark opened this issue Jun 15, 2022 · 2 comments

Comments

@brittainmark
Copy link

Trying to add product location to easypolulate. Using code you supplied.
The issue I have is it does not like the left join.

MySQLi error 1054: Unknown column 'p.products_id' in 'on clause'
When executing:
SELECT    
          p.products_id         as v_products_id,
          p.products_type         as v_products_type,
          p.products_model        as v_products_model,
          p.products_image        as v_products_image,
          p.products_price        as v_products_price,
          pl.vs_products_location as v_vs_products_location,p.products_qty_box_status as v_products_qty_box_status,p.products_quantity_order_max as v_products_quantity_order_max,p.products_weight      as v_products_weight,
          p.products_discount_type    as v_products_discount_type,
          p.products_discount_type_from   as v_products_discount_type_from,
          p.product_is_call       as v_product_is_call,
          p.products_sort_order     as v_products_sort_order,
          p.products_quantity_order_min as v_products_quantity_order_min,
          p.products_quantity_order_units as v_products_quantity_order_units,
          p.products_priced_by_attribute  as v_products_priced_by_attribute,
          p.product_is_always_free_shipping as v_product_is_always_free_shipping,
          p.products_date_added     as v_date_added,
          p.products_date_available   as v_date_avail,
          p.products_tax_class_id     as v_tax_class_id,
          p.products_quantity       as v_products_quantity,
          p.products_status       as v_products_status,
          p.manufacturers_id        as v_manufacturers_id,
          p.metatags_products_name_status as v_metatags_products_name_status,
          p.metatags_title_status     as v_metatags_title_status,
          p.metatags_model_status     as v_metatags_model_status,
          p.metatags_price_status     as v_metatags_price_status,
          p.metatags_title_tagline_status as v_metatags_title_tagline_status,
          subc.categories_id        as v_categories_id
          FROM products as p, products_to_categories as ptoc,categories as subc  LEFT JOIN very_simple_products_location AS pl ON (pl.products_id = p.products_id) WHERE
          p.products_id      = ptoc.products_id AND
          ptoc.categories_id = subc.categories_id AND 
            p.products_model   = '21TR008P'

I have played around with the SQL and the issue appears to be that the left join is trying to join to ptoc.categories.

If I move the join

FROM products as p LEFT JOIN very_simple_products_location AS pl ON (pl.products_id = p.products_id) , 
products_to_categories as ptoc, categories as subc  

Works fine.

It also works if all joins are used

FROM products AS p INNER JOIN products_to_categories AS ptoc ON p.products_id = ptoc.products_id 
INNER JOIN categories AS subc  ON ptoc.categories_id = subc.categories_id 
LEFT JOIN very_simple_products_location AS pl ON (pl.products_id = p.products_id) 
WHERE p.products_model = '21TR008P'

I was wondering If you would like me to go through and rewrite all the selects to use JOIN and submit as a PR?

PHP Version 8.0
MYSQL Ver 8.0.29-0ubuntu0.20.04.3
Zen cart 1.5.8.

@mc12345678
Copy link
Owner

If not mistaken, I had also recently run into this issue and had made changes on my development server to use the ANSI-92 style referenced by use of inner joins, etc...

Give me a little bit of time to merge that and a few other improvements to the latest branch of this repo before you devote too much time to resolving.

I will push something that will relate to this issue or post something back as applicable.

@brittainmark
Copy link
Author

I have created a temporary fix for myself by changing lines 257-259 of easypopulate_4_import.php
from

FROM ' .
                TABLE_PRODUCTS . ' as p, ' .
                TABLE_PRODUCTS_TO_CATEGORIES . ' as ptoc,' .
                TABLE_CATEGORIES . ' as subc ';

to

FROM ' .
                TABLE_PRODUCTS_TO_CATEGORIES . ' as ptoc,' .
                TABLE_CATEGORIES . ' as subc ' .
                TABLE_PRODUCTS . ' as p, ' ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants