Jump to content

Edit History

krypt

krypt

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!

krypt

krypt

Goodmorning everyone,

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

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!

×
×
  • Create New...