由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 请教一个mysql 排序问题。
相关主题
SQL combine two columns from two different tables no shared (转载)In MySQL, 如何在procedure里create trigger?谢谢了?
问个笨问题MySQL语句请教
这个sql语句怎么写MySQL语句请教
random sampling with replacement, how?help about SQL for ACCESS
mysql maximum columns <=1000?请问一个SQL语句的优化问题
请问sql语句能不能实现这样的功能SQL 分类汇总 并且按照汇总值排序
请问mysql这个语句如何写?How to replace 0 with empty?
这“精妙sql语句”是错误的吗请教SQL server的一个programming的问题,谢谢
相关话题的讨论汇总
话题: table话题: select话题: where话题: mysql话题: 排序
进入Database版参与讨论
1 (共1页)
P********l
发帖数: 29
1
sql 语句为
select id from table where id in (1,2,5,4,3)
能否以1 2 5 4 3 得到排序结果,语句如何写?
B*****g
发帖数: 34098
2
mysql is hot now.
http://www.w3schools.com/SQL/sql_orderby.asp

【在 P********l 的大作中提到】
: sql 语句为
: select id from table where id in (1,2,5,4,3)
: 能否以1 2 5 4 3 得到排序结果,语句如何写?

P********l
发帖数: 29
3
似乎不能解决我的问题。
我想要记录集结果按照in的括号里面的顺序排列,而不是按照他的id
B*****g
发帖数: 34098
4
Got you, don't know much about mysql.
below is my solution for oracle.
CREATE OR REPLACE
TYPE IDCOLLECTION AS TABLE OF NUMBER;
SELECT t1.*
FROM table t1,
(SELECT COLUMN_VALUE id,
ROWNUM seqno
FROM TABLE (idcollection (1,2,5,4,3))) t2
WHERE t1.id = t2.id
ORDER BY t2.seqno;

【在 P********l 的大作中提到】
: 似乎不能解决我的问题。
: 我想要记录集结果按照in的括号里面的顺序排列,而不是按照他的id

a*******s
发帖数: 324
5
stupid solution
select id from table where id = 1 union select id from table where id = 2
union select id from table where id = 5 union .....

【在 P********l 的大作中提到】
: sql 语句为
: select id from table where id in (1,2,5,4,3)
: 能否以1 2 5 4 3 得到排序结果,语句如何写?

B*****g
发帖数: 34098
6
see "stupid solution", think you are replying my post.
haha. btw ,should be "union all" ba

【在 a*******s 的大作中提到】
: stupid solution
: select id from table where id = 1 union select id from table where id = 2
: union select id from table where id = 5 union .....

1 (共1页)
进入Database版参与讨论
相关主题
请教SQL server的一个programming的问题,谢谢mysql maximum columns <=1000?
Oracle,table有上千个column请问sql语句能不能实现这样的功能
SQL combine two tables into one table and add a new column请问mysql这个语句如何写?
compare two large tables SQL (转载)这“精妙sql语句”是错误的吗
SQL combine two columns from two different tables no shared (转载)In MySQL, 如何在procedure里create trigger?谢谢了?
问个笨问题MySQL语句请教
这个sql语句怎么写MySQL语句请教
random sampling with replacement, how?help about SQL for ACCESS
相关话题的讨论汇总
话题: table话题: select话题: where话题: mysql话题: 排序