Skip to content

Instantly share code, notes, and snippets.

@scottcrawford03
Created August 15, 2018 21:40
Show Gist options
  • Save scottcrawford03/2d50d8210b74964eec0832fa4d827879 to your computer and use it in GitHub Desktop.
Save scottcrawford03/2d50d8210b74964eec0832fa4d827879 to your computer and use it in GitHub Desktop.
select recommendations.link, recommendations.recommendation_type, recommendations.title, profile_question_options.option_data, recommendations.profile_question_option_id, recommendations.priority
from recommendations
inner join profile_question_options on profile_question_options.id = recommendations.profile_question_option_id
where (recommendations.priority=2 and recommendations.recommendation_type='article' and recommendations.profile_question_option_id in` + oneClickParams + `)
or (recommendations.recommendation_type='article' and recommendations.profile_question_option_id in` + questionOptionQueryParam + `)
order by recommendations.priority
limit 7;
-- I want records that match the first where clause to be returned at the top and then i want to order the results of the second where clause by their priority.
-- If i were to do this with two queries i'd basically just make the first where cluase and add it to an array and then make the second where clause and append it to that same array.
-- i.e. combining two datasets from the same table where the second dataset is orderd by a column and the first data set is just matching something specific.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment