Skip to content

Instantly share code, notes, and snippets.

@hobodave
Created March 20, 2012 21:54
Show Gist options
  • Save hobodave/2141690 to your computer and use it in GitHub Desktop.
Save hobodave/2141690 to your computer and use it in GitHub Desktop.
SELECT
q.question_id, q.text
FROM survey_question q
JOIN survey_question_folder f1 USING(question_folder_id)
JOIN survey_question_folder ancestors ON f1.path LIKE CONCAT(ancestors.path, '%')
WHERE
q.text LIKE '%new%'
OR f1.name LIKE '%new%'
OR ancestors.name LIKE '%new%'
GROUP BY q.question_id ORDER BY NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment