mysql> use mysql; 进入到mysql库里 类似系统命令cd mysql> show tables; 显示所在库下已有的表 (表用来存数据的文件 ) 查看表里的所有行 select 表头名列表 from 库名.表名; 仅查看与条件匹配的行 selec 输出时定义列名 mysql> select "abc" as 字母t 表头名列表 from 库名.表名 where 查询条件 ;
1、定义别名 使用 as 或 空格 mysql> select 表头1,表头2 from tarena.user; mysql> select 表头1 as 用户名 , 表头2 家目录 from ”库.表“;
2、数据拼接 concat() mysql> select 表头1,表头2 from ”库.表“; 以下同理; mysql> select concat(name,"-",uid) from tarena.user; mysql> select concat(name,"-",uid) as 用户信息 from tarena.user;
3、去重显示 distinct 字段名列表 mysql> select shell from tarena.user; 有重复 mysql> select distinct shell from tarena.user; 去重