) table_a order by table_a.count desc
2张表关联排序,用union来做.SELECT * FROM (SELECT id,ach,'X' AS counter,'A' AS class,date FROM tablename1 as t1 WHERE 1 UNION SELECT id,ach,counter,'B' AS class,date FROM tablename2 as t2 WHERE 1) AS tall order by date asc
建议增加条件,且为索引字段.其次查的数据量不能太大,不然临时表会占据较多的内存空间.宁可牺牲硬盘空间,也不要无谓的牺牲内存空间.
从长远角度来说,建议整合2个表.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)