n*u
2 楼
Sorry to bother high hands again. Thanks for your help before!
Table a, articleid (pk), userid, datetime, textbody
Table b, userid (pk), nickname
I want one record, that's the latest article, with nickname, datetime and
textbody.
So I wrote this:
SELECT a.DateTime,b.Nickname,a.textbody
FROM a, b
WHERE a.userid=b.userid
ORDER BY datatime DESC
LIMIT 0, 1
But I feel this might be slow. Any way to make it fast?
I told my team leader we should write this as a stored procedure, but he
refused.
Table a, articleid (pk), userid, datetime, textbody
Table b, userid (pk), nickname
I want one record, that's the latest article, with nickname, datetime and
textbody.
So I wrote this:
SELECT a.DateTime,b.Nickname,a.textbody
FROM a, b
WHERE a.userid=b.userid
ORDER BY datatime DESC
LIMIT 0, 1
But I feel this might be slow. Any way to make it fast?
I told my team leader we should write this as a stored procedure, but he
refused.
q*x
3 楼
赞!
背景那个四个圈圈是纸的装饰,还是用来方便控制字体大小的啊?
背景那个四个圈圈是纸的装饰,还是用来方便控制字体大小的啊?
c*d
4 楼
1. create index on table_a (datetime)
2. select ... from a, b where a.userid=b.userid and a.datetime=(select max(d
atetime) from a
【在 n****u 的大作中提到】
: Sorry to bother high hands again. Thanks for your help before!
: Table a, articleid (pk), userid, datetime, textbody
: Table b, userid (pk), nickname
: I want one record, that's the latest article, with nickname, datetime and
: textbody.
: So I wrote this:
: SELECT a.DateTime,b.Nickname,a.textbody
: FROM a, b
: WHERE a.userid=b.userid
: ORDER BY datatime DESC
2. select ... from a, b where a.userid=b.userid and a.datetime=(select max(d
atetime) from a
【在 n****u 的大作中提到】
: Sorry to bother high hands again. Thanks for your help before!
: Table a, articleid (pk), userid, datetime, textbody
: Table b, userid (pk), nickname
: I want one record, that's the latest article, with nickname, datetime and
: textbody.
: So I wrote this:
: SELECT a.DateTime,b.Nickname,a.textbody
: FROM a, b
: WHERE a.userid=b.userid
: ORDER BY datatime DESC
n*6
6 楼
未经测试。
SELECT a.articleid, ...., max(a.datetime), ...
FROM a, b
WHERE a.userid = b.userid
【在 n****u 的大作中提到】
: Sorry to bother high hands again. Thanks for your help before!
: Table a, articleid (pk), userid, datetime, textbody
: Table b, userid (pk), nickname
: I want one record, that's the latest article, with nickname, datetime and
: textbody.
: So I wrote this:
: SELECT a.DateTime,b.Nickname,a.textbody
: FROM a, b
: WHERE a.userid=b.userid
: ORDER BY datatime DESC
SELECT a.articleid, ...., max(a.datetime), ...
FROM a, b
WHERE a.userid = b.userid
【在 n****u 的大作中提到】
: Sorry to bother high hands again. Thanks for your help before!
: Table a, articleid (pk), userid, datetime, textbody
: Table b, userid (pk), nickname
: I want one record, that's the latest article, with nickname, datetime and
: textbody.
: So I wrote this:
: SELECT a.DateTime,b.Nickname,a.textbody
: FROM a, b
: WHERE a.userid=b.userid
: ORDER BY datatime DESC
f*n
7 楼
我更喜欢左边的题字,嘻嘻
n*u
9 楼
Thanks, it did improve the query speed. Cut off time more than 50%!
相关阅读
how to remote access to SQLserver DB?MySQL configuration file in windows?how to check transaction一个关于right join的问题Kuehle,AW Re: 问问学过oracle9i DBA课程的的同学们请问哪里可以下载 Visual C++h-d nearest neighbor searchquestion on create a db manually[转载] Oracle DBA 主要需要注意什么?database design issueAn oracle installation error on Linux 9How to install Oracle9i Database options问个excel的问题???请问有没有SQLSServer Driver for UNIX?恢复SQL Server2000数据库(在线等)数据库在教育领域能作何应用?Mysql中怎么解决添加大型数据产生的问题use DBI in ApacheSQL语句执行速度与CPU个数和内存大小有多大关系?[转载] 求教:没有任何编程经验的人,