简体   繁体   中英

MySQL: Get multiple row's different values to one single column

This is my table structure

My table name siteInfo

id    | key         | value

1     | facebook    | facebook.com

2     | twitter     | twitter.com

3     | googleplus  | google.com

4     | linkedin    | linkedin.com

here how i can get facebook and googleplus values from single sql column

I think this is what you are looking for,

select group_concat(`value` separator ', ') url
from siteinfo
where `key` in ('facebook','googleplus');

here is, SQLFiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM