Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- selection_id | group_id | selection_group_id |
- ------------------------------------------------
- 1 1 1
- selector_id | selection_id | name | index
- ------------------------------------------
- 1 1 Step1 0
- 2 1 Step2 1
- 3 1 Step3 2
- select selector_id
- from selectors s
- group by selector_id
- having max(case when name = 'Step1' then 1 else 0 end) = 1 and
- max(case when name = 'Step2' then 1 else 0 end) = 1 and
- max(case when name = 'Step3' then 1 else 0 end) = 1 and
- max(case when name in ('Step1', 'Step2', 'Step3') then 0 else 1 end) = 0
- select selector_id
- from selectors s
- group by selector_id
- having count(distinct name) = 3 and
- max(case when name in ('Step1', 'Step2', 'Step3') then 0 else 1 end) = 0
- SELECT selection_id, GROUP_CONCAT(name)
- FROM selectors
- SELECT DISTINCT Selection_ID
- FROM (
- SELECT selection_id, GROUP_CONCAT(name) gc
- FROM selectors
- ) t
- WHERE gc = 'Step1,Step2,Step3'
- SELECT selections.selection_id FROM `prstshp_productsort_groups_selections` selections
- WHERE EXISTS (SELECT * FROM `prstshp_productsort_groups_selectors` s3
- WHERE s3.name = "Muskelaufbau" AND s3.index = 0 AND s3.selection_id = selections.selection_id)
- AND
- EXISTS (SELECT * FROM `prstshp_productsort_groups_selectors` s4
- WHERE s4.name = "Mesomorph" AND s4.index = 1 AND s4.selection_id = selections.selection_id)
- AND
- EXISTS (SELECT * FROM `prstshp_productsort_groups_selectors` s5
- WHERE s5.name = "Männlich" AND s5.index = 2 AND s5.selection_id = selections.selection_id)
- AND
- EXISTS (SELECT * FROM `prstshp_productsort_groups_selectors` s6
- WHERE s6.name = "25-40" AND s6.index = 3 AND s6.selection_id = selections.selection_id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement