SELECT texts.Type,phone.Name,texts.To,texts.Message,texts.Date,texts.Time FROM texts JOIN phone on texts.To = phone.Phone WHERE texts.GalleryId = ORDER BY Date DESC, Time DESC