SELECT s.*, k.address FROM student s
INNER JOIN address k
ON instr(s.fulladdress, k.address) > 0
WHERE j.phonetic like '%california%'
此结果将显示2行,包含2部分地址:
30,Andre Hans, Address 1 Address 2,class IBA1001, Address 1
30,Andre Hans, Address 1 Address 2,class IBA1001, Address 2
我想将它显示在一行中:
30,Andre Hans, Address 1 Address 2,class IBA1001, Address 1 | Address 2
我怎么能这样做?
答案 0 :(得分:0)
使用group by
和group_concat
:
SELECT s.*, group_concat(k.address separator ' | ') FROM student s
INNER JOIN address k
ON instr(s.fulladdress, k.address) > 0
WHERE j.phonetic like '%california%'
GROUP BY s.col1, s.col2 .... -- all the columns in table student