Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Not Unique Table/Alias problem


phoenixx5

Recommended Posts

I'm getting the following error after installing Products Extra Fields v2.0j on the advanced_search_result.php page.

 

1066 - Not unique table/alias: 'p'

 

select count(distinct p.products_id) as total from (products p left join products_to_products_extra_fields p2pef on p.products_id=p2pef.products_id) left join manufacturers m on m.manufacturers_id=p.manufacturers_id, products_description p left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%phoenixx%' or p.products_model like '%phoenixx%' or m.manufacturers_name like '%phoenixx%' or p2pef.products_extra_fields_value like '%phoenixx%') )

 

Here is the original and modified code that I installed on that page that is creating the problem. By the way the phoenixx is the term I searched for.

// BEGIN ORIGINAL AND MODIFIED CODE FROM CONTRIBUTION - PRODUCTS EXTRA FIELDS V2.0J (06.29.09)
//  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";
// END ORIGINAL AND MODIFIED CODE FROM CONTRIBUTION - PRODUCTS EXTRA FIELDS V2.0J (06.29.09)

// BEGIN CONTRIBUTION - PRODUCTS EXTRA FIELDS V2.0J (06.29.09)
 $from_str = "from (" . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef on p.products_id=p2pef.products_id) left join " . TABLE_MANUFACTURERS . " m on m.manufacturers_id=p.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
// END CONTRIBUTION - PRODUCTS EXTRA FIELDS V2.0J (06.29.09)

Link to comment
Share on other sites

1066 - Not unique table/alias: 'p'

 

select count(distinct p.products_id) as total from (products p left join products_to_products_extra_fields p2pef on p.products_id=p2pef.products_id) left join manufacturers m on m.manufacturers_id=p.manufacturers_id, products_description p left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%phoenixx%' or p.products_model like '%phoenixx%' or m.manufacturers_name like '%phoenixx%' or p2pef.products_extra_fields_value like '%phoenixx%') )

The error is pointing out that products_description p should be products_description pd. However, if you made that change, you would get a new error, as you have two copies each of pd, p2c, and c. As best I can tell from looking at what you posted and a stock osC, the contribution predates a change to display tax rates. If you revert to the previous version of the file, and just change

" . TABLE_PRODUCTS . " p

to

(" . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef on p.products_id=p2pef.products_id)

without making any other changes to the $from_str, it should fix your issue. I.e. if I'm looking at the right place, the final result would look like

  $from_str = "from (" . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef on p.products_id=p2pef.products_id) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";

You should verify that though. I'm guessing based on what you posted and trying to correlate it with a stock osC. I may have missed something and certainly haven't tested.

 

If you get this working, it would help if you could update the contribution for others.

 

In the future, it would be more appropriate to post questions like this in the Contributions General Support forum rather than the main one. Preferably in the support thread devoted to the contribution.

Always back up before making changes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...