:SELECT tng_people.living, lnprefix, suffix, tng_people.branch,lastname, firstname,birthdate,birthplace,if(sex='M',families1.marrplace,families2.marrplace),if(sex='M',families1.marrdate,families2.marrdate),(if(sex='M',families1.wife,families2.husband)) as spouse,deathdate,deathplace,sex,e123.eventplace as eventplace123,e123.eventdate as eventdate123, tng_people.personID, tng_people.gedcom, nameorder FROM (tng_people ) LEFT JOIN tng_families AS families1 ON (tng_people.gedcom = families1.gedcom AND tng_people.personID = families1.husband ) LEFT JOIN tng_families AS families2 ON (tng_people.gedcom = families2.gedcom AND tng_people.personID = families2.wife ) LEFT JOIN tng_events e123 ON tng_people.personID = e123.persfamID AND tng_people.gedcom = e123.gedcom AND e123.eventtypeID = "123" WHERE (tng_people.personID = "P2521846828" ) AND tng_people.gedcom = "tree16" ORDER BY e123.eventdate