SELECT u.*,i.* 这是什么意思==================================================================
SELECT t.*,a.* FROM discuz1.cdb_threads t INNER JOIN discuz1.cdb_attachments a ON t.tid=a.tid WHERE a.isimage=1 and t.attachment=1 group by t.tid ORDER BY t.views DESC 就是上面的语句,
discuz1.cdb_threads,discuz1.cdb_attachments 这两个为主题表和附件表,discuz1为我的论坛数据库,cdb为数据表前缀,threads和attachments就不用我说了。
t.tid代表thread表里面的tid,同理为a.tid;a.isimage表示attachment表里面的isimage字段,用于判断附件是否为图像,1为true,0为false(这个很必要,不然有些附件不是图片调用出来会显示红X);t.attachment,估计是用于判断是否有附件的,和a.isimage一个理。
ORDER BY t.views DESC:按查看数递减排列,===================================================我实在看不懂啊,那个t.*,a.*是什么意思,还有 inner join是什么玩意小弟只会写简单的语句,希望各位大侠指教
SELECT t.*,a.* FROM discuz1.cdb_threads t INNER JOIN discuz1.cdb_attachments a ON t.tid=a.tid WHERE a.isimage=1 and t.attachment=1 group by t.tid ORDER BY t.views DESC 就是上面的语句,
discuz1.cdb_threads,discuz1.cdb_attachments 这两个为主题表和附件表,discuz1为我的论坛数据库,cdb为数据表前缀,threads和attachments就不用我说了。
t.tid代表thread表里面的tid,同理为a.tid;a.isimage表示attachment表里面的isimage字段,用于判断附件是否为图像,1为true,0为false(这个很必要,不然有些附件不是图片调用出来会显示红X);t.attachment,估计是用于判断是否有附件的,和a.isimage一个理。
ORDER BY t.views DESC:按查看数递减排列,===================================================我实在看不懂啊,那个t.*,a.*是什么意思,还有 inner join是什么玩意小弟只会写简单的语句,希望各位大侠指教
A:discuz1.cdb_attachments 表别名
INNER JOIN:内连接 条件是t.tid=a.tid
select i.* from customer i;
相当于
select id,name,password from customer;
明白否?
正解.
[align=center]==== 思想重于技巧 ====
[/align]
.
贴子分数<20:对自已的问题不予重视。
贴子大量未结:对别人的回答不予尊重。
.