I have the following SQL SELECT
statement that aliases the result of a CROSS JOIN
:
SELECT tx.K,tx.J,tx.t
FROM (
J1_TBL CROSS JOIN J2_TBL
) AS tx
ORDER BY tx.K,tx.J,tx.t
This works fine on PostgreSQL and DB2 LUW, but fails on MariaDB 10.5 with
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS tx ORDER BY tx.K,tx.J,tx.t' at line 1
So how do I alias the result of the CROSS JOIN
in MariaDB?
CodePudding user response:
How do I alias the result of a JOIN
Make a working query. Wrap it in parenthesis.
SELECT
tx.K, tx.J, tx.t
FROM (
SELECT
J1_TBL.K, J2_TBL.J, J2_TBL.t
FROM
J1_TBL CROSS JOIN J2_TBL
) AS tx
ORDER BY
tx.K,tx.J,tx.t