Jump to content

Add Order Date Inside SQL Request


PabloGutierrez

Recommended Posts

Hello!

I have the following SQL request in Prestashop's backoffice and works perfectly, showing me the coupon codes that have been used with specific characteristics:

SELECT * FROM  ps_order_cart_rule WHERE id_order_invoice>0 AND name LIKE '%[%'

However, I need to view the order date when the coupon code was used (as a column). I suppose I need to use SQL joins but I haven't been able to make it work.

Can someone please guide me?

Thanks for your help! 

Link to comment
Share on other sites

Hello, you can try:

SELECT ocr.id_order, o.date_add FROM  ps_order_cart_rule ocr Inner join ps_orders o on (ocr.id_order = o.id_order) WHERE id_order_invoice>0 AND name LIKE '%[%' 

or

Select o.id_order, o.date_add from ps_orders o where o.id_order in (SELECT ocr.id_order FROM  ps_order_cart_rule ocr WHERE id_order_invoice>0 AND name LIKE '%[%')

 

Link to comment
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
×
×
  • Create New...