Size: a a a

2020 December 08

VD

Volodymyr Dzhuryn in Evolution CMS
Kévin Zanon
Hi! Can I ask you a question about MySQL?
yes, you can
источник

KZ

Kévin Zanon in Evolution CMS
Thanks 😊 So, I want to display 6 results order by createdon. So far, it's easy. But. For the 3 first rows, I want to display 3 specifics id in a specific order. How can I do that?
источник

E

EVO bot Лёшка in Evolution CMS
Kévin Zanon
Thanks 😊 So, I want to display 6 results order by createdon. So far, it's easy. But. For the 3 first rows, I want to display 3 specifics id in a specific order. How can I do that?
источник

KZ

Kévin Zanon in Evolution CMS
Am I clear?
источник

KZ

Kévin Zanon in Evolution CMS
In a first place I added ORDER BY field(id,21,11) AND createdon DESC but it didn't work (basically it starts by 11, then 21) and if I replace createdon by menuindex id = 21  isn't displayed, that's why I think it's not a good method.
источник

МН

Михаил Носков... in Evolution CMS
Kévin Zanon
In a first place I added ORDER BY field(id,21,11) AND createdon DESC but it didn't work (basically it starts by 11, then 21) and if I replace createdon by menuindex id = 21  isn't displayed, that's why I think it's not a good method.
hi, you should use FIND_IN_SET
источник

KZ

Kévin Zanon in Evolution CMS
FIND_IN_SET('21,11', id) doesn't work
источник

KZ

Kévin Zanon in Evolution CMS
No result
источник

KZ

Kévin Zanon in Evolution CMS
Plus, FIND_IN_SET have the exactly the result that if I use WHERE id = 21
источник

KZ

Kévin Zanon in Evolution CMS
I want to display id = 21, then 11, then the others results until I have 6 results
источник

МН

Михаил Носков... in Evolution CMS
ORDER BY FIND_IN_SET( id, '11,21' ) DESC , createdon DESC
источник

U

Umka in Evolution CMS
Andrey K
А чем выводится там?
это в админке выводится у ресурса
источник

К

Камиль in Evolution CMS
источник

KZ

Kévin Zanon in Evolution CMS
Михаил Носков
ORDER BY FIND_IN_SET( id, '11,21' ) DESC , createdon DESC
It seems to work, except for the order. I wrote (id, '21,11') and it display 11 then 21.
источник

KZ

Kévin Zanon in Evolution CMS
And if I write FIND_IN_SET( id, '21,11' ) ASC = 21 is the last result and 11 isn't displayed
источник

KZ

Kévin Zanon in Evolution CMS
😭
источник

DK

Denis Korolev in Evolution CMS
@Neoziox order by case when id =21 then 0 when id=11 then 1 else 2 end id and created_on desc try this
источник

DK

Denis Korolev in Evolution CMS
not sure about correct syntax
источник

KZ

Kévin Zanon in Evolution CMS
I have this WHERE ( id IN('21', '11') OR parent = '9' ) AND c.parent IN ('9') AND c.deleted = 0 AND c.published = 1 GROUP BY c.id ORDER BY case id when 21 then 10 when 11 then 20 else 100 end and menuindex DESC LIMIT 0, 3
R
esult: 11, 23, 24 -> where is 21?
источник

DM

Dmytro Makohonenko in Evolution CMS
order by field(id, 21,11), createdon desc - don't use "and " between two sorting fields, only comma
источник