当前位置:Gxlcms > mysql > 【MySQL】命令行执行sql,去除字段名

【MySQL】命令行执行sql,去除字段名

时间:2021-07-01 10:21:17 帮助过:84人阅读

mysql的-e选项可以让我们在命令行下执行sql: /bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -e select id from {table_name} where uid=1; ------- | id | ------- | 10162 | | 10151 | | 10152 | ------- 发现上面带了字段名id,

mysql的-e选项可以让我们在命令行下执行sql:

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -e "select id from {table_name} where uid=1;"
+-------+
| id |
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+


发现上面带了字段名id,去掉字段名可以用-N选项(--skip-column-names(-N)):

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -Ne "select id from {table_name} where uid=1;"
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+


参考:http://blog.sina.com.cn/s/blog_71fbce730100obnq.html

人气教程排行