繁体   English   中英

mysql合并两个表并排序结果

[英]mysql union of two tables and order the results

请原谅我的无知。 我想对表invcount2和reserve1进行合并。 下面的代码有什么错误?

mysql_query("select distinct Name from exam1sem.invcount2  WHERE Name not in 
(select  Name from exam1sem.invcount2 where Date='$date' AND Time='$time'
 union select  Name from exam1sem.reserve1 where Date='$date' AND 
Time='$time') 

union

select distinct Name from exam1sem.reserve1 WHERE Name not in (select  Name 
from exam1sem.invcount2 where Date='$date' AND Time='$time'
union select  Name from exam1sem.reserve1 where Date='$date' AND 
Time='$time'
)  

order by Avail, TD, NOD
");

看来,当您使用distinct关键字时,您无法按select语句中不存在的内容进行order by

您可以检查此SQL链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM