首页 > 数据库 >数据库 - 第六次实验

数据库 - 第六次实验

时间:2024-02-29 14:23:03浏览次数:71  
标签:video uid vid 数据库 watch 实验 user 第六次 SELECT

a)

SELECT * 
FROM video 
WHERE vid=35

结果:

b)

SELECT user.*   
FROM user JOIN post ON user.uid = post.uid   
WHERE post.vid = 35

结果:

c)

SELECT count(*) 
FROM watch 
WHERE vid=35

结果:

d)

SELECT count(*) 
FROM like 
WHERE vid=35

结果:

e)

SELECT count(*) 
FROM collect 
WHERE vid=35

结果:

f)

SELECT sum(coin.amount) 
FROM coin 
WHERE vid=35

结果:

g)

SELECT * 
FROM comment 
WHERE vid=35 
ORDER BY video_time ASC

结果:

SELECT user.nickname,count(post.vid)
FROM user JOIN post ON user.uid = post.uid  
GROUP BY user.uid, user.nickname  
ORDER BY count(post.vid) DESC  
LIMIT 5

结果:

SELECT user.nickname,user.profile,user.userlevel, count(follow.uid_followed)
FROM user JOIN follow ON user.uid = follow.uid_followed
GROUP BY user.nickname,user.profile,user.userlevel
ORDER BY count(follow.uid_followed) DESC
LIMIT 10

结果:

SELECT video.name,video.description,count(watch.vid)
FROM video JOIN watch ON video.vid = watch.vid
GROUP BY video.name,video.description,video.vid
ORDER BY count(watch.vid) DESC
LIMIT 10

结果:

SELECT video.chanel,count(watch.vid)
FROM video JOIN watch ON video.vid = watch.vid
GROUP BY video.chanel

结果:

SELECT video.name,count(watch.uid)
FROM watch JOIN video ON watch.vid = video.vid
WHERE video.chanel = '美食'
GROUP BY video.vid
ORDER BY count(watch.uid) DESC
LIMIT 5

结果:

SELECT video.chanel,count(watch.vid)
FROM watch JOIN video ON watch.vid = video.vid
WHERE watch.uid = 15
GROUP BY video.chanel
ORDER BY count(watch.vid) DESC
LIMIT 5

结果:

SELECT video.name,video.description
FROM user JOIN watch ON watch.uid = user.uid
          JOIN video ON watch.vid = video.vid
WHERE user.uid = 15 AND watch.time > 900

结果:

SELECT user.nickname,user.profile,user.userlevel
FROM user JOIN follow ON user.uid = follow.uid_follower
WHERE follow.uid_followed = 15

结果:

SELECT video.name,video.description,post.post_time
FROM video JOIN post ON video.vid = post.vid
           JOIN follow ON post.uid=follow.uid_followed
WHERE follow.uid_follower = 15
ORDER BY post.post_time DESC

结果:

SELECT user.nickname,user.profile,user.userlevel
FROM user JOIN follow f1 ON user.uid = f1.uid_followed
          JOIN follow f2 ON user.uid = f2.uid_follower
WHERE f1.uid_follower = 15 AND f2.uid_followed = 15

结果:

标签:video,uid,vid,数据库,watch,实验,user,第六次,SELECT
From: https://www.cnblogs.com/XiaoZhenglld/p/18043580

相关文章

  • 数据库 - 第五次实验
    SELECTcommodity.name,onsell.status,onsell.rem_amount,AVG(orders.buyerrate),COUNT(*)FROMonsellJOINordersONonsell.cid=orders.cidANDonsell.sid=orders.sidJOINcommodityONonsell.cid=commodity.cidWHEREonsell.cid=2410AND......
  • 数据库 - 第四次实验
    a)SELECTPeople.pid,People.name,City.nameFROMPeopleJOINCityONPeople.cid=City.cidWHEREPeople.pid=1结果:b)SELECTvaccine.name,count(*)FROMpeopleJOINinoculateONpeople.pid=inoculate.pidJOINvaccineONinoculate.vcid=vacc......
  • 数据库 - 第三次实验
    CREATEVIEWuser_friendASSELECTu2.uid,u2.nickname,f1.note,f1.typeFROMuseru1JOINfriendf1ONu1.uid=f1.uid1JOINuseru2ONu2.uid=f1.uid2WHEREu1.uid=1;运行SELECT*FROMuser_friend;结果:![[Pastedimage202311141727......
  • Oracle 12C数据库从文件系统迁移到ASM
     查看参数文件位置SQL>showparameterspfileNAMETYPEVALUE-----------------------------------------------------------------------------spfilestring/u01/app/oracle/product/12.......
  • 国产数据库兼容性认证再下两城,极狐GitLab 国产适配更进一步
    近日,极狐GitLab与两大国产数据库TDSQL和人大金仓完成兼容性认证。极狐GitLab在国产化适配、国产化生态建设上有了进一步的发展。极狐GitLab团队分别和TDSQL和人大金仓数据库团队做了严格的测试验证,完成了这两大国产数据库和极狐GitLab企业级一体化DevOps平台的兼容性认......
  • FastAPI系列:fastapi定制的数据库操作库sqlmodel
    官网sqlmodel安装#安装sqlmodel会自动安装pydantic和sqlalchemypipinstallsqlmodel使用#步骤1,创建sqlmodel引擎fromsqlmodelimportcreate_engine#driver://用户名:密码@ip/数据库engine=create_engine("mysql+mysqldb://root:123456@localhost/api")#步骤......
  • DM数据库几种主备模式说明
    前言DM数据库的主备集群主要是由搭建数据守护的方式来实现。DM数据守护(DMDataWatch)的实现原理非常简单:将主库(生产库)产生的Redo日志传输到备库,备库接收并重新应用Redo日志,从而实现备库与主库的数据同步。在此基础下,DM通过一些参数和接口的控制可以实现实时主备、读写分离集群......
  • 数据库 Tips
    数据库Tips时间和日期互转数据库当前时间字符串转时间时间转字符串格式dual表MySQLNOW()STR_TO_DATEDATE_FORMAT%Y-%m-%d%H:%i:%s可选OracleSYSTIMESTAMP、SYSDATETO_TIMESTAMP、TO_DATETO_CHARYYYY-MM-DDHH24:MI:SS必须用PostgreSQLCURRENT_......
  • Mybatis 批量更新 PostgreSQL 数据库,返回更新行数
    1.拼接成1条sql语句,可返回修改行数。PostgreSQL的批量更新原生sql:updatepersonsetname=tmp.name,age=tmp.age,addr=tmp.addr,num=tmp.num,update_time=tmp.update_timefrom(values(1,'关羽',43,'成都',1,'2021-03-2617:32:2......
  • 国产化数据库选型
    背景政府型等企业对视频会议产品有国产化方需求,其中包括国产化服务器、国产化操作系统、国产化数据库、国产化软件等,特别是国产化服务器和国产操作系统、国产化数据库,有特别明确。目前我司已选型国产化服务器为:曙光CPU,海光机器,操作系统为:KyLin-Server-V10-SP1。需求分析原私有......