Hello everyone, I had a problem when choosing a category tree. Here is the request I am sending.

SELECT DISTINCT category.id, category.parent_id, category.name FROM category JOIN category_closure ON category.id = category_closure.descendant WHERE category_closure.ancestor > 1; 

This query only works in Mysql 5.7, and in Mysql 5.6 does not work. Update Mysql is not an option Answer Mysql 5.7 Answer Mysql 5.6 Base

  • And what is the MySQL server response to 5.6? - users
  • Works like a regular select without join - Nicholas
  • Is it possible to see the structure of tables without downloading files from the poison? - vp_arth
  • Maybe this option? pastebin.com/MEr7E9eu - users
  • I agree with @vp_arth, it is desirable to use a similar service: pastebin.com or say gist.github.com - users

1 answer 1

Your request (mainly due to DISTINCT ) is no different from:

 SELECT category.id, category.parent_id, category.name FROM category WHERE category.id > 1 
  • The whole point is that my query works on mysql5.7, and your query worked the same way as mine did on mysql5.6. That is, the join does not do what it should do, therefore at 5.6 my query works like a normal select - Nicholas
  • How many lines do you get as a result of 5.7? Not 44? - vp_arth
  • Yes, 44 and at 5.6 are also 44, but they are in a different order - Nicholas
  • This should be the order: parent 1 children 1 children 1 parent 2 children 2 parent 3 children 3 chidlren 3 - Nicholas
  • one
    What order are we talking about if ORDER BY missing? - user236014