gpt4 book ai didi

mysql - 从表中获取一行并将其放在查询的第一个位置

转载 作者:行者123 更新时间:2023-11-29 04:43:14 24 4
gpt4 key购买 nike

我想知道是否存在一种通过 MySQL 从表中获取行并将其放在结果查询的第一个位置的方法。例如

这是表格

1 Item_1
2 Item_2
3 Item_3
4 Item_4

例如,当我请求 Item_3 时,我希望得到这样的结果:

3 Item_3
1 Item_1
2 Item_2
4 Item_4

有可能吗

最佳答案

select * from your_table
order by case when column_2 = 'Item_3'
then 1
else 2
end asc,
other_column_Order asc

或者尤其是 MySQL

select * from your_table
order by column_2 <> 'Item_3',
other_column_Order asc

关于mysql - 从表中获取一行并将其放在查询的第一个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24183151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com