Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

douglaswalker

Help with SQL

Recommended Posts

Hi there

I am trying to access 3 tables in Oscommerce Database to pull some orders showing products and attributes but cant get it to work. Just says I have an error in my SQL

I am selecting from orders  and  orders_products and orders_products_attributes  linked by orders_id...

 

This is the original

$products_query = tep_db_query("SELECT  op.products_model, op.orders_id, op.products_quantity FROM orders_products op LEFT JOIN orders o ON op.orders_id = o.orders_id where op.orders_id IN (" . $orders_implode . ") and op.clubosc_shipping_type != 'dropshipped' ORDER BY op.orders_id DESC, op.products_id DESC");
    

This is what I have attempted

$products_query = tep_db_query("SELECT  op.products_model, op.orders_id, op.products_quantity, opa.orders_id, opa.products_options_values, FROM orders_products op, orders_products_attributes opa LEFT JOIN orders o ON op.orders_id = o.o orders_id JOIN orders_products op ON opa.orders_id = op.op orders_id where opa.orders_id IN (" . $orders_implode . ") and op.clubosc_shipping_type != 'dropshipped' ORDER BY op.orders_id DESC, op.products_id DESC");
    

 

Edited by douglaswalker

Share this post


Link to post
Share on other sites
On 7/16/2022 at 8:22 AM, douglaswalker said:

op.orders_id = o.o orders_id

 


No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Share this post


Link to post
Share on other sites
$products_query = tep_db_query("SELECT  op.products_model, op.orders_id, op.products_quantity, opa.orders_id, opa.products_options_values FROM

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×