Jump to content

Query SELECT not exist with UNION ALL


krypt
 Share

Recommended Posts

Goodmorning everyone,

I'm new to the forum and to using prestashop.

I don't know if it's the right section to ask.

I made a query to extract data with SELECT joined together with the UNION ALL. I tested it in the Back Office, in Database-> SQL Manager. When I save the query I get the message "SELECT does not exist". If I use a UNION instead of UNION ALL, it works.

The curious thing is that the same query tested directly by phpmyadmin works.

Have you ever understood such a thing?

I did a counter test even with a more "simple" query and the result is always the same: with UNION ALL error, with UNION it works.

This is the code of the "simple" and also bizarre test, but I just needed to understand.

SELECT
    orderId,
    orderReference
FROM
(SELECT
    o.`id_order` AS `orderId`,
    o.`reference` AS `orderReference`
FROM `ps_orders` o
WHERE o.`reference` IN (210460,210267,210423,210405,210446)
) AS orderDat

UNION ALL

SELECT
    orderId,
    orderReference
FROM
(SELECT
    '***' AS `orderId`,
    o.`reference` AS `orderReference`
FROM `ps_orders` o
WHERE o.`reference` IN (210460,210267,210423,210405,210446)
) AS discountDat

Thank you very much!

Edited by krypt (see edit history)

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More