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%!
相关阅读
中国人SQL SERVER用户组呢?微软这次整改总部最少得雷4,5千人吧 (转载)有谁知道产生这两个ORA error的原因?Uncommited transaction 能写到 log嘛? sql serverMS SQL Server 的 bulk insert permission简历以后不写毕业年份了同事忽然殷勤起来了CINAOUG/CINASSUG讲座-Oracle数据库架构及备份学一门语言需要多久耐心看完这贴,再考虑转行cs的事情。有人在准备MSSQL 70-433 吗?请问:关于做大数据处理和mongoDB的工作,前景如何文科出身在top it工作读information sysyem 前景请各位大狭Refer一下Oracle DBA的工作.很安靜被刺激一下,然后又继续麻木了今天见识了做 oracle的印度大军了搞一个SOLUTION ARCHITECTURE的讲座怎么样夜深了,又孤独的守在电脑旁十大杰出青年的下场