You will first want to ORDER BY such that all rows that have no have a middle name at located at the bottom of each id
. So for example ORDER BY first ORDER BY middle
then perform SELECT DISTINCT(*) FROM <table_name> WHERE (first IS NOT NULL) AND (last IS NOT NULL)
. This will grab the last entry of each id
with the middle name if it has one otherwise it will just grab it without a middle name. This assumes that each person has a first and last name.
0
solved How to select a record with more information?