Last active
August 22, 2019 14:47
-
-
Save tolyod/5d27f5cb7bf18dd063a4b1ea3b95b51d to your computer and use it in GitHub Desktop.
netcat catalogs sql query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set @parent_product_category := 1780; | |
SET group_concat_max_len = 40960; | |
select group_concat(catalog_row SEPARATOR '\r\n') from ( select if(Parent_Sub_ID != @parent_product_category, | |
concat('<category id="',Subdivision_ID,'" parentId="', Parent_Sub_ID,'">', Subdivision_Name,'</category>'), | |
concat('<category id="',Subdivision_ID,'">', Subdivision_Name,'</category>') | |
) as catalog_row | |
from ( | |
select Subdivision_ID, Subdivision_Name, Parent_Sub_ID | |
from svetdepo.Subdivision | |
where Subdivision_ID in ( | |
SELECT Parent_Sub_ID FROM svetdepo.Subdivision | |
where Subdivision_ID in ( | |
SELECT distinct Subdivision_ID FROM svetdepo.Message217 | |
) | |
and Subdivision_Name != 'Импорт' | |
) | |
union | |
SELECT Subdivision_ID, Subdivision_Name, Parent_Sub_ID | |
FROM svetdepo.Subdivision | |
where Subdivision_ID in ( | |
SELECT distinct Subdivision_ID | |
FROM svetdepo.Message217 | |
) | |
and Subdivision_Name != 'Импорт' | |
) t | |
where Parent_Sub_ID != 0 | |
order by Parent_Sub_ID) t2; |
Author
tolyod
commented
Aug 22, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment