Hello
There is one weird thing going on in the query below :
For an unknow reason, the number of character of all the results issued by
CONCAT() can't be superior to the length __STRING__.
If I replace "__STRING__" by nothing, the column test will be
empty for all records. If I replace "__STRING__" by "ab", all
the records for test will only show the first two characters.
Can someone explain what's going on?
Thanks!
There is one weird thing going on in the query below :
For an unknow reason, the number of character of all the results issued by
CONCAT() can't be superior to the length __STRING__.
If I replace "__STRING__" by nothing, the column test will be
empty for all records. If I replace "__STRING__" by "ab", all
the records for test will only show the first two characters.
Can someone explain what's going on?
Thanks!
Code:
SELECT
t1.*
, '__STRING__' as test
FROM
ecom_prod_cats AS t1
WHERE
t1.cat_parent_ID = "2"
UNION ALL
SELECT
t2.*
, CONCAT(t1.cat_ID, '.', t2.cat_ID) as test
FROM ecom_prod_cats AS t1
INNER JOIN ecom_prod_cats AS t2 ON t2.cat_parent_ID = t1.cat_ID
AND (t1.cat_ID = "13" OR t1.cat_ID = "17")
WHERE
t1.cat_parent_ID = "2"
UNION ALL
SELECT
t3.*
, CONCAT(t1.cat_ID, '.', t2.cat_ID, '.', t3.cat_ID) AS test
FROM ecom_prod_cats AS t1
INNER JOIN ecom_prod_cats AS t2 ON t2.cat_parent_ID = t1.cat_ID
INNER JOIN ecom_prod_cats AS t3 ON t3.cat_parent_ID = t2.cat_ID
AND (t1.cat_ID = "13" OR t1.cat_ID = "17")
WHERE
t1.cat_parent_ID = "2"
UNION ALL
SELECT
t4.*
, CONCAT(t1.cat_ID, '.', t2.cat_ID, '.', t3.cat_ID, '.', t4.cat_ID) AS test
FROM ecom_prod_cats AS t1
INNER JOIN ecom_prod_cats AS t2 ON t2.cat_parent_ID = t1.cat_ID
INNER JOIN ecom_prod_cats AS t3 ON t3.cat_parent_ID = t2.cat_ID
INNER JOIN ecom_prod_cats AS t4 ON t4.cat_parent_ID = t3.cat_ID
AND (t1.cat_ID = "13" OR t1.cat_ID = "17")
WHERE
t1.cat_parent_ID = "2"
ORDER BY t1.cat_parent_ID, cat_ID