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%!
相关阅读
Re: How to concatenate NULL value with a string in SQL Server?Re: 为什么有的电影必须要去电影院看?a complex sql query, high hand help!!![转载] 嵌入式数据库如何烦译成英文?Oracle 求助Question on relational calculusNo Need for trigger Re: oracle trigger questionfrom where can i get the acamedic info on Databas怎样安装MySQL++?Advanced QueueDUMMY question: Intro to SQL.Oracle8i 启动问题multicolumn primary key ?Where can I download Pro*C/C++ precompiler? Thanks a lot!oracle trigger question卧春荒凉啊,只有问问题的,没有答问题的:(如何在oracle8i中得到视图和表的定义?Where can I get some intro for PL/SQL?Help!!!