午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

mysql - 數(shù)據(jù)庫JOIN查詢

瀏覽:191日期:2022-06-13 17:56:36

問題描述

問題解答

回答1:

drop table if exists article;drop table if exists category;drop table if exists r_ac;create table article(id serial not null,title varchar(100),expire timestamp,primary key(id));create table category(id serial not null,name varchar(50),primary key(id));create table r_ac(article int not null,category int not null,primary key(article, category));insert into article(title, expire) values (’a’, ’2017-05-20’),(’b’, null),(’c’, ’2017-03-04’),(’d’, ’2017-02-23’),(’e’, ’2017-04-23’),(’f’, ’2016-09-15’),(’g’, ’2017-06-09’);insert into category(name) values (’c1’),(’c2’),(’c3’),(’c4’),(’c5’),(’c6’),(’c7’);insert into r_ac (article, category) values(1, 1), (1, 2), (1, 5), (1, 7),(2, 1), (2, 6),(3, 5),(4, 1), (4, 4),(7, 1), (7, 7);select category, c.name, count(1) as c from r_ac as acinner join (select id, title, expire from article where expire is null or expire>now()) as z on ac.article=z.idleft join category as c on ac.category=c.idgroup by category, c.name;回答2:

select c.id,count(a.id) from category c LEFT JOIN r_ac r on r.category=c.idLEFT JOIN article a on a.id=r.article and ifnull(a.expire>NOW(),1)GROUP BY c.id

相關(guān)文章:
主站蜘蛛池模板: 一区二区三区视频在线 | 久久草草| 亚洲不卡影院 | 黄色大片视频网站 | 黄色大片免费网站 | 色网站入口 | 日韩精品中文字幕在线观看 | 国产精品原创 | 日本中文字幕一区 | 99视频国产精品免费观看a | 免费成人在线播放 | 亚洲蜜臀av乱码久久精品蜜桃 | 男人天堂手机在线 | 五月婷婷激情视频 | 黄色一级大片在线免费看国产一 | 91av导航| 国产天堂网 | 麻豆av在线播放 | 黄色精品在线 | 一区二区精品国产 | 午夜男人的天堂 | 日韩精品一区二区三区在线观看 | 国外成人在线视频 | 色婷婷婷 | 国产伦理自拍 | 欧美超逼视频 | 草视频在线| 日韩视频在线观看免费视频 | 中文字幕第23页 | 高清不卡一区二区 | 欧美视频一区在线 | 黄色片网站在线免费观看 | 黄色免费在线观看网站 | 性生活短视频 | 久久成年人视频 | 亚洲婷婷免费 | 亚洲男人第一天堂 | 99在线免费视频 | 四虎啪啪 | 成人短视频在线观看 | 中文字幕1 |