Tang Taizong's famous saying "You can learn from people's mistakes and gains by learning from others." The "learning from people" here generally refers to the experience and lessons of people's success and failure.
Confucius' famous saying in "The Analects of Confucius" "When you see a virtuous person, think about them; when you see a virtuous person, you should reflect on yourself." The words "virtuous" and "unvirtuous" here refer to: people's ability level.
And another famous saying of Confucius in "The Analects of Confucius" "Choose what is good and follow it, and change what is not good". The "good ones" and "bad ones" here refer to the advantages and disadvantages shown by people according to moral norms.
It is precisely because people's success and failure are related to their own ability level and their own strengths and weaknesses, so Tang Taizong's famous saying "You can know your gains and losses by learning from others" can completely be compared with Confucius's "The Analects" The famous saying "When you see a good person, think about it; when you see a bad person, you should reflect on yourself", and "Choose the good ones and follow them, and change the bad ones".