当前位置: 代码迷 >> J2SE >> mysql 两表之间的查询 各位大侠帮帮忙,该怎么处理
  详细解决方案

mysql 两表之间的查询 各位大侠帮帮忙,该怎么处理

热度:93   发布时间:2016-04-24 12:26:57.0
mysql 两表之间的查询 各位大侠帮帮忙
有两张表 一张表 字段 id 和 name 另一张表 id 和 time(字段类型:datetime) 
查询结果 有姓名和时间 排列方式是以离今日最近的日期排序

大家帮帮忙~~~急

------解决方案--------------------
select name, time
from table1, table2
where table1.id = table2.id
order by time desc;
------解决方案--------------------
SQL code
SELECT name, time FROM table1, table2WHERE table1.id = table2.idORDER BY time DESC
------解决方案--------------------
探讨

SQL code

SELECT name, time FROM table1, table2
WHERE table1.id = table2.id
ORDER BY time DESC

------解决方案--------------------
探讨

select name, time
from table1, table2
where table1.id = table2.id
order by time desc;

------解决方案--------------------
SQL code
   select A.name , B.time  from  table1 A ,table2 B    where  A.id = B.id   order by timestampdiff(second,now(),B.time) asc
  相关解决方案