Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何在desc中排序我的sql值_Mysql_Sql_Sql Server - Fatal编程技术网

Mysql 如何在desc中排序我的sql值

Mysql 如何在desc中排序我的sql值,mysql,sql,sql-server,Mysql,Sql,Sql Server,您需要在SQL语句末尾添加orderby 尝试: 看起来像是sql server。请删除不需要的标签。并且要弄清楚您试图复制的内容。您应该阅读关于连接的内容,并使用它们,而不是列中的子查询。然后使用一些别名,以便知道每列来自哪个表。 SELECT Distinct ', '+ (select text from dbo.codelists where id = LoadReferenceTypeId), ': ' + ReferenceValue FROM dbo.LoadReference

您需要在SQL语句末尾添加
orderby

尝试:


看起来像是
sql server
。请删除不需要的标签。并且要弄清楚您试图复制的内容。您应该阅读关于连接的内容,并使用它们,而不是列中的子查询。然后使用一些别名,以便知道每列来自哪个表。
SELECT Distinct ', '+ (select text from dbo.codelists 
where id = LoadReferenceTypeId), ': ' +  ReferenceValue FROM dbo.LoadReferences 
WHERE LoadId = 89 and EndDate IS NULL 
SELECT Distinct ', '+ 
(
  select text from dbo.codelists 
  WHERE id = LoadReferenceTypeId
)
, ': ' +  ReferenceValue 
FROM dbo.LoadReferences 
WHERE LoadId = 89 and EndDate IS NULL
ORDER BY column_name DESC;