mercredi 13 janvier 2016

How to select distinct records?

Column number may have have duplicates. How can I select records, which gets distinct row by number?

SELECT contacts_table._id AS _id, title, title_short,  DISTINCT number, note, categories, contacts_categories_name, contact_id, contacts_categories_catalog_id 
FROM contacts_table LEFT OUTER JOIN contacts_categories_table ON(contacts_categories_contact_id = contact_id AND contacts_categories_current_user = current_user)  
WHERE ((current_user = ? AND saved =? AND ( title LIKE ? OR  number LIKE ? OR note LIKE ? ) ) AND (contacts_categories_catalog_id = ? )) ORDER BY contacts_categories_name = 'UNSORTED' DESC, contacts_categories_name ASC, title ASC

Aucun commentaire:

Enregistrer un commentaire