mercredi 14 octobre 2015

PHP PDO SQlite single query to find result with only one occurence

For example, I have the following table:

 id  Name - Target 
 1    A       B     
 2    C       D      
 3    E       D   

I actually have over 2 million records.

My goal is to query "Target" for "D", and return "D" data only if there is a single record of "D", in my example the query must fail because there are 2 records of "Target" with value of "D".

I tried to use count records and check if the returning query has more than one hit, but is very slow.

Is there a better approach ?

Thank you

Aucun commentaire:

Enregistrer un commentaire