数据调用的sql语句
- 提问者网友:鼻尖触碰
- 2021-05-10 20:21
- 五星知识达人网友:孤独入客枕
- 2021-05-10 21:38
1. SELECt * FROM `uchome_blog` WHERe `picflag` =1;
复制代码
2、调用最近更新的10条日志
1. SELECt * FROM uchome_blog FORCE INDEX(dateline) ORDER BY dateline DESC LIMIT 0,10;
复制代码
3、调用最近更新的10个相册
1. SELECt * FROM uchome_album FORCE INDEX(updatetime) ORDER BY dateline DESC LIMIT 0,10;
复制代码
说明:这是调用所有相册
加个条件:调用隐私设计为全站可见的相册
1. SELECT * FROM uchome_album FORCE INDEX(updatetime) WHERe `friend` =0 ORDER BY dateline DESC
复制代码
说明:friend值: '0'全站用户可见,'1'为全好友可见,'2'为仅指定的好友可见,'3'为仅自己可见,'4'为凭密码查看
4、调用最近的10条迷你博客
1. SELECT * FROM uchome_doing FORCE INDEX(dateline) ORDER BY dateline DESC LIMIT 0,10;
复制代码
5、调用我的话题
1. SELECt * FROM uchome_thread ORDER BY dateline DESC LIMIT 0,10;
复制代码
6、调用3天内回复数最多的日志
1. SELECt * FROM uchome_blog WHERe dateline>UNIX_TIMESTAMP()-86400*3 ORDER BY replynum DESC
复制代码
7、调用选吧一周内的热点话题
1. select * FROM uchome_thread where dateline>=UNIX_TIMESTAMP()-604800 ORDER BY viewnum DESC;
复制代码
或者
1. SELECt * FROM uchome_ thread WHERe dateline>=UNIX_TIMESTAMP()-86400*7 ORDER BY viewnum DESC;
复制代码
8、调用最近3天注册的人,且按照降序排列
1. SELECt * FROM uchome_space WHERe dateline>UNIX_TIMESTAMP()-86400*3 ORDER BY dateline DESC;
复制代码
9、调用最后更新的10位会员
1. select * from uchome_space order by updatetime desc LIMIT 0,10;
复制代码
10、将用户栏目的内容列表出来,并以用户积分作为排列顺序
1. SELECT * FROM uchome_spacefield sf, uchome_space s WHERe s.uid=sf.uid order by s.credit desc
复制代码
说明:field_1为 uchome_spacefield 这个表要调用的用户栏目选择项,可以为field_1,field_2。。。
11、调用个人空间性别为女的用户
1. select * from uchome_space s,uchome_spacefield sf where s.uid=sf.uid and sf.sex=2
复制代码
12、调用个人空间性别为男的用户
1. select * from uchome_space s,uchome_spacefield sf where s.uid=sf.uid and sf.sex=1
复制代码
13、调用积分高的前10个会员
1. select * from uchome_space order by credit desc LIMIT 0,10;
复制代码
14、调用访问量最大的空间
1. select * from uchome_space order by viewnum desc LIMIT 0,10;
复制代码
15、调用指定用户的日志
1. SELECt * FROM `uchome_blog` WHERe uid =1 LIMIT 0 , 10
复制代码
这是调用uid为1的10条记录
16、调用有头像的10个会员
1. SELECt * FROM `uchome_space` WHERe `avatar` =1 LIMIT 0 , 10
复制代码
17、调用某一主题回复的内容
1. SELECt * FROM `uchome_post` WHERe tid =1 AND isthread =0 LIMIT 0 , 30;
复制代码
上面的SQL语,可以调用主题id为1的30条回复
18、调用群组
1. SELECt * FROM `uchome_mtag` LIMIT 0 , 10
复制代码
19、调用一周热门会员
1. select * from uchome_space WHERe dateline>=UNIX_TIMESTAMP()
2. -3600*24*7 ORDER BY viewnum DESC LIMIT 0,18
复制代码
本文出自:第九区 www.th9qu.com 转截请注明。否则必究!!