I have multiple lines of data
id name amt
1 506 100
1 505 100
2 308 20
2 606 20
id There's a lot of , First of all name The original name, The second is name The new name,amt There will be no change , The effect you want to achieve is
id primary name new name amt
1 506 505 100
2 308 606 20
Perform associated query on its own table .
select d a.id,a.name ' primary name',b.name1 ' new name',a.amt from surface a, surface b where a.id=b.id and a.name<>b.name group by a.id;
doubt ： What is the only key in the table , There is no unique column .
If help , Please accept . Click on the top right corner of my answer 【 Adopt 】 Button .
You're wrong . You have a field in front of this id,name,amt. Your needs now become id,name,name2,amt. Don't you need to add a field ？
Lack of conditions , How to distinguish the original name New name