简体   繁体   中英

MySQL Workbench: merging multiple rows into one row using same call_ID

The data is like:

CallID | callin | callout

 456   |  16267777 | *123

   456 | *123      |19095351

  789  | 1323789   |  *123

   789 |  *123     |180515978

(*123 is the system extension number )

Table name : call_history

Now I want to regroup the data to become:

 CallID           callin           callout

 456             16267777         19095351

 789             1323789          180515978

How do I do it ? By using Selfjoin? GROUP?

Thank you!

You can use an inner join

select a.callID, a.callin, b.callout
from call_history as  a 
inner join call_history as b on a.callID = b.callID
where a.callin !='*123' 
and b.callout !='*123'

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