描述
题目:现在运营想要查看用户信息表中所有的数据,请你取出相应结果
示例:user_profile
id | device_id | gender | age | university | province |
1 | 2138 | male | 21 | 北京大学 | Beijing |
2 | 3214 | male | 复旦大学 | Shanghai | |
3 | 6543 | female | 20 | 北京大学 | Beijing |
4 | 2315 | female | 23 | 浙江大学 | ZheJiang |
5 | 5432 | male | 25 | 山东大学 | Shandong |
根据示例,你的查询应返回以下结果:
id | device_id | gender | age | university | province |
1 | 2138 | male | 21 | 北京大学 | Beijing |
2 | 3214 | male | 复旦大学 | Shanghai | |
3 | 6543 | female | 20 | 北京大学 | Beijing |
4 | 2315 | female | 23 | 浙江大学 | Zhejiang |
5 | 5432 | male | 25 | 山东大学 | Shandong |
示例1
输入:
drop table if exists user_profile; CREATE TABLE `user_profile` ( `id` int NOT NULL, `device_id` int NOT NU服务器托管网LL, `gender` varchar(14) NOT NULL, `age` int , `university` varchar(32) NOT NULL, `province` varchar(32) NOT NULL); INSERT INTO user_profile VALUES(1,2138,'male',21,'北京大学','BeiJing'); INSERT INTO user_profile VALUES(2,3214,'male',null,'复旦大学','Shanghai'); INSERT INTO user_profile VALUES(3,6543,'female',20,'北京大学','BeiJing'); INSERT INTO user_profile VALUES(4,2315,'female',23,'浙江大学','ZheJiang'); INSERT INTO user_profile VALUES(5,5432,'male',25,'山东大学','Shandong');
复制输出:
1|2138|male|21|北京大学|BeiJing 2|3214|male|None|复旦大学|Shanghai 3|6543|female|20|北京大学|BeiJing 4|2315|female|23|浙江大学|ZheJiang 5|5432|male|25|山东大学|Shandong
题解
select
id,device_id,gender,age,university,province
from user_profile
或者
select
*
from user_profile
实际应用中一般写列名,很少用*号。
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: Oracle数据库升级PostgreSQL 后的踩坑记录(一)之databaseId
背景:因为业务需求,需要整个项目除了适配oracle和mysq服务器托管网l后还需要适配PostgreSQL,在此背景下就出现了一系列的问题。 踩坑一:databaseId 连接数据库后启动发现某些查询报错传入的sql参数是空,经过反复排查定位到对应的MyBa…