当前位置: 首页 > news >正文

公司网站微信平台建设的好处站长之家工具查询

公司网站微信平台建设的好处,站长之家工具查询,宁波网站建设公司哪家好,网站常用文件夹例题: 创建如下两张表 分别命名为books和persons (1)按照书名,姓名的顺序列出字里包含‘德’字的人物的姓名,书名和字。 select name 姓名,bookname 书名,style 字 from books,persons where style like %德% and bo…

例题:

创建如下两张表 分别命名为books和persons

 

(1)按照书名,姓名的顺序列出字里包含‘德’字的人物的姓名,书名和字。

select name 姓名,bookname 书名,style 字
from books,persons
where style like '%德%'
and books.bookid = persons.bookid
order by 2,1;

order by 2,1:先按照书名排序,书名相同再按照姓名排序:一般是按照首字母排序

 

(2)哪本书中的人物姓名包含最多‘悟’字?
第一种表示方法:

select bookname 书名
from books,persons
where persons.bookid=books.bookid
and name like '%悟%'
group by bookname
having count(books.bookid)=(select top 1 count(bookid)
from persons
where name like '%悟%'
order by count(bookid) desc)

第二种表示方法:

select bookname 书名 from books
where bookid in(
select bookid from persons
where name like'%悟%’
group by bookid
having count(*) =(
select top (1) count(*) from persons
where name like'%悟%’
group by bookid
order by 1 desc))

count(字段)和count(*)的区别:

count(*) 是统计行数,

count(字段) 是统计字段列非null的行数

在查询字段非null时,两者的查询结果是一样的

补充:

count(1)也是统计行数

对于count(1)和count(*)返回的结果是一样的,但是两者的效率在不同的情况下不同:

如果表中没有主键 ,使用count(1)比count(*)快;

如果有主键,那么count(主键)最快

详细的内容,推荐这篇:http://t.csdn.cn/AiVUl

(3)人物最多的书的男性人物的姓名和字是什么

select name 姓名,style 字
from persons
where sex='男'
and bookid in(select bookid from persons
group by bookid 
having count(bookid) =(select top 1 count(bookid) from persons
group by bookid
order by count(bookid) desc))

 

(4)哪本书的人物姓名都是三个字的

select bookname 书名
from books
where bookid not in(select bookid from persons
where name not in(select name from persons where len(name)=3))

(5)女性人物最多的书是哪个朝代的

select dynasty 朝代
from books
where bookid in (
select bookid from persons
where sex ='女’
group by bookid
having count(*)=(
select top(1) count(*) from persons
where sex='女
group by bookid
order by 1 desc

 

 

(6)与唐僧在同一本书的女性人物是谁?

select name 姓名 from books,persons
where books.bookid in(select books bookid from books,persons
where books.bookid=persons.bookid
and name ='唐僧')
and books.bookid=persons.bookid
and sex='女';

(7) 有女性人物但是女性人物最少的书:

select distinct bookname书名,author作者
from books.persons
where books.bookid=persons.bookid
and books.bookid in 
select bookid from persons
where sex ='女'
group by bookid
having count(*) =(
select top(1) count(*)
from persons
where sex='女'
group by bookid
order by 1 asc))

 

http://www.tj-hxxt.cn/news/48215.html

相关文章:

  • 微信公众号是在哪个网站做的百度站长平台如何添加网站
  • 代网站建设中国新冠疫苗接种率
  • 品牌平价网站建设自己开发网站
  • 江门企业免费建站互联网营销师培训教程
  • 拼多多卖网站建设mac923水蜜桃923色号
  • 营销型企业网站的提出免费开网店免费供货
  • 做详情页比较好的网站销售平台
  • 织梦网站栏目是做什么用的百度搜索引擎投放
  • 网站如何提高转化率郑州网站建设公司
  • 大型银行网站建设lpl赛区战绩
  • 郑州免费网站制作2023年5月份病毒感染情况
  • 搭建个人网站赚钱百度导航怎么下载
  • 免费网站模板下载网站搜索引擎排名中国
  • 商丘网站建设费用怎么引流推广自己的产品
  • 东莞网站制作百年百度广告代理商
  • 网络服务商基本网络参数seo排名关键词搜索结果
  • 怎么做自己的网站卖东西网络营销与直播电商怎么样
  • 专业网站改版网络推广中心
  • win服务器做网站电脑培训班
  • 蓝牙音箱东莞网站建设seo优化专员工作内容
  • 策划方案万能模板seo关键词推广话术
  • Wordpress订阅栏目seo与sem的关系
  • 通信管理局网站备案济南seo怎么优化
  • 南京疫情今天最新情况地址查询深圳网站seo公司
  • 有什么有趣的网站长沙网站seo优化公司
  • 如何帮别人推广赚钱济南seo外包服务
  • 注册公司的流程图页面关键词优化
  • 如何外贸seo网站建设seo关键词优化软件官网
  • 虚拟机wordpress教程视频搜索引擎排名优化建议
  • 电商网站建设任务分解结构抖音seo关键词排名技术