学习笔记

MySQL 数据库操作

数据库中有表 members(id、username、post_number、pass、email) 和表 posts(id、members_id、title、content、add_time)

1. 取出表 members 中发帖数量 (post_number) 前10位的名字

select username,post_number from members order by posts_number desc limit 10;

2. 名字为 join 的最新10个发帖的标题

select title from posts where id=(select id from members where username=”join”) order by add_time desc limit 10;

select username.title from members as m join posts as p on m.id=p.members_id where m.username=”join” order by p.add_time desc limit 10;

发表评论

电子邮件地址不会被公开。 必填项已用*标注