当前位置:网站首页>牛客刷SQL--5
牛客刷SQL--5
2022-08-01 13:42:00 【小唐同学(๑><๑)】
作者简介:大家好我是小唐同学(๑><๑),大家可以叫我小唐
个人主页:小唐同学(๑><๑)的博客主页
系列专栏:数据库
博友们如果也是新手入门MySQL 我希望大家可以多加练习 MySQL题库在牛客网就有已经给大家附上链接,可以直接点击跳转:点击跳转
牛客网支持ACM模式哦,刷算法题也很推荐哦!!!
下面上文章------》
目录
SQL15 查看学校名称中含北京的用户
描述
题目:现在运营想查看所有大学中带有北京的用户的信息,请你取出相应数据。
示例:用户信息表:user_profile
id device_id gender age university gpa 1 2138 male 21 北京大学 3.4 2 3214 male 复旦大学 4.0 3 6543 female 20 北京大学 3.2 4 2315 female 23 浙江大学 3.6 5 5432 male 25 山东大学 3.8 6 2131 male 28 北京师范大学 3.3 根据示例,你的查询应返回如下结果:
device_id age university 2138 21 北京大学 6543 20 北京大学 2131 28 北京师范大学 示例1
输入:
drop table if exists user_profile; CREATE TABLE `user_profile` ( `id` int NOT NULL, `device_id` int NOT NULL, `gender` varchar(14) NOT NULL, `age` int , `university` varchar(32) NOT NULL, `gpa` float); INSERT INTO user_profile VALUES(1,2138,'male',21,'北京大学',3.4); INSERT INTO user_profile VALUES(2,3214,'male',null,'复旦大学',4.0); INSERT INTO user_profile VALUES(3,6543,'female',20,'北京大学',3.2); INSERT INTO user_profile VALUES(4,2315,'female',23,'浙江大学',3.6); INSERT INTO user_profile VALUES(5,5432,'male',25,'山东大学',3.8); INSERT INTO user_profile VALUES(6,2131,'male',28,'北京师范大学',3.3);复制输出:
2138|21|北京大学 6543|20|北京大学 2131|28|北京师范大学
select device_id,age,university from user_profile where university like '%北京%';SQL15 查看学校名称中含北京的用户
描述
题目:现在运营想查看所有大学中带有北京的用户的信息,请你取出相应数据。
示例:用户信息表:user_profile
id device_id gender age university gpa 1 2138 male 21 北京大学 3.4 2 3214 male 复旦大学 4.0 3 6543 female 20 北京大学 3.2 4 2315 female 23 浙江大学 3.6 5 5432 male 25 山东大学 3.8 6 2131 male 28 北京师范大学 3.3 根据示例,你的查询应返回如下结果:
device_id age university 2138 21 北京大学 6543 20 北京大学 2131 28 北京师范大学 示例1
输入:
drop table if exists user_profile; CREATE TABLE `user_profile` ( `id` int NOT NULL, `device_id` int NOT NULL, `gender` varchar(14) NOT NULL, `age` int , `university` varchar(32) NOT NULL, `gpa` float); INSERT INTO user_profile VALUES(1,2138,'male',21,'北京大学',3.4); INSERT INTO user_profile VALUES(2,3214,'male',null,'复旦大学',4.0); INSERT INTO user_profile VALUES(3,6543,'female',20,'北京大学',3.2); INSERT INTO user_profile VALUES(4,2315,'female',23,'浙江大学',3.6); INSERT INTO user_profile VALUES(5,5432,'male',25,'山东大学',3.8); INSERT INTO user_profile VALUES(6,2131,'male',28,'北京师范大学',3.3);复制输出:
2138|21|北京大学 6543|20|北京大学 2131|28|北京师范大学
select device_id,age,university from user_profile where university like '%北京%';
边栏推荐
- 关于Request复用的那点破事儿。研究明白了,给你汇报一下。
- SQL function SQRT
- 论文笔记All about Eve: Execute-Verify Replication for Multi-Core Servers
- Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
- 库函数的模拟实现(strlen)(strcpy)(strcat)(strcmp)(strstr)(memcpy)(memmove)(C语言)(VS)
- AI目标分割能力,无需绿幕即可实现快速视频抠图
- 【StoneDB Class】Introduction Lesson 2: Analysis of the Overall Architecture of StoneDB
- windows IDEA + PHP+xdebug 断点调试
- 什么是元编程
- Six Stones Programming: Problems must be faced, methods must be skillful, and functions that cannot be done well must be solved
猜你喜欢

【码蹄集新手村600题】判断一个数字是否为完全平方数

Efficiency tools to let programmers get off work earlier

论文笔记All about Eve: Execute-Verify Replication for Multi-Core Servers

PanGu-Coder:函数级的代码生成模型

What is consistent hashing?In what scenarios can it be applied?

Based on 10 years of experience in stability assurance, what are the three key questions to be answered in failure recovery?|TakinTalks big coffee sharing

态路小课堂丨浅谈优质光模块需要具备的条件!

性能测试入门指南

mysql的基本使用

RGB系列开发稳定响应快速灯带拾音灯氛围灯等应用定制方案
随机推荐
【每日一题】1331. 数组序号转换
Qt实战案例(56)——利用QProcess实现应用程序重启功能
制售假劣农资、非法占用耕地……公安部公布十起危害粮食生产安全犯罪典型案例
多线程案例——阻塞式队列
Istio Pilot代码深度解析
态路小课堂丨浅谈优质光模块需要具备的条件!
【无标题】
软件测试之发现和解决bug
Based on 10 years of experience in stability assurance, what are the three key questions to be answered in failure recovery?|TakinTalks big coffee sharing
postgresql之page分配管理(一)
易优压双驱挖掘机压路机器类网站源码 v1.5.8
批量替换Word中的表格为图片并保存
六石编程学:问题要面对,办法要技巧,做不好的功能要想办法
leetcode: 1201. Ugly Number III [Dichotomy + Mathematics + Inclusion and Exclusion Principle]
Multithreading Case - Timer
AD单片机九齐单片机NY8B062D SOP16九齐
PanGu-Coder:函数级的代码生成模型
AI目标分割能力,无需绿幕即可实现快速视频抠图
tensorflow2.0 handwritten digit recognition (tensorflow handwriting recognition)
sql is not null 优化(oracle语句索引优化)