Home > Mobile >  I can't select unique text from template_id
I can't select unique text from template_id

Time:03-27

select template_id, text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
limit 2

What i have

|template_id |text |

| 26 | you have a bonuce/azmm/eee
| 26 | you have a bonuce/azmm/fff

What i need

|template_id |text |

| 26 | you have a bonuce/azmm/eee
| 217 | you are winner /azmm/fff

What i tried

select template_id, text
from questionary_eventlog qe
where template_id in (26, 217)
and
text = (select distinct left(text,17) from questionary_eventlog
group by template_id
limit 2

CodePudding user response:

You may want a correct group by aggregation

select template_id, max(text) text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
  • Related