当前位置:网站首页>牛客刷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 '%北京%';
边栏推荐
- D - I Hate Non-integer Number(背包dp)
- 测试发文
- 程序员的浪漫七夕
- PAT1166 Summit(25)
- 高仿项目协作工具【Worktile】,从零带你一步步实现组织架构、网盘、消息、项目、审批等功能
- 制售假劣农资、非法占用耕地……公安部公布十起危害粮食生产安全犯罪典型案例
- 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
- 力扣160题,相交链表
- E - Red and Blue Graph(组合数学)
- 代理商替代义隆153 Aip4210
猜你喜欢
随机推荐
动态库、静态库浅析
iframe tag attribute description detailed [easy to understand]
LeetCode_动态规划_中等_313.超级丑数
什么是混合元编程
2022图片在线加水印源码
人像分割技术解析与应用
SQL functions STR
NebulaGraph v3.2.0 性能报告
又拿三个大奖?!多力就是要让你吃的更营养更健康
软件测试之发现和解决bug
Batch replace tables in Word with pictures and save
芝加哥丰田技术学院 | Leveraging Natural Supervision for Language Representation Learning and Generation(利用自然监督进行语言表示学习和生成)
AI目标分割能力,无需绿幕即可实现快速视频抠图
嵌入式开发:创建和使用可移植类型的7个技巧
意大利普拉托华社将游行示威 盼解决安全问题
JMP Pro 16.0 software installation package download and installation tutorial
魔众文档管理系统 v5.0.0
数据挖掘-04
VIP的实现原理
RGB系列开发稳定响应快速灯带拾音灯氛围灯等应用定制方案








