日期:2014-05-20  浏览次数:20706 次

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, table2
WHERE table1.id = table2.id
ORDER 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