2016-08-24 1 views
0

Tableau de données:Comment gérer la valeur de champ nul lors de l'utilisation COMME

enter image description here

J'ai ce script sql:

SELECT 
    ei.objid 
FROM entityindividual ei 
INNER JOIN entity e 
    ON ei.objid = e.objid 
LEFT JOIN entity_address ea 
    ON ei.objid = ea.parentid 
WHERE ei.gender = 'M' 
AND ISNULL(ea.barangay_name) LIKE '%' 

Si vous exécutez ce script, 6 enregistrements seront affichés , mais sans utiliser ISNULL(ea.barangay_name), seul 1 enregistrement sera affiché.

Mais considérez ce scénario:

SELECT 
    ei.objid 
FROM entityindividual ei 
INNER JOIN entity e 
    ON ei.objid = e.objid 
LEFT JOIN entity_address ea 
    ON ei.objid = ea.parentid 
WHERE ei.gender = 'M' 
AND ISNULL(ea.barangay_name) LIKE '%BUENAVISTA%' 

Le PROBLÈME est aucun enregistrement affichera lorsque vous exécutez au-dessus du script. POURQUOI? Comment réparer celui-ci?

+0

exactement ce que tu fais ici? 'AND ISNULL (ea.barangay_name) LIKE '%'' – e4c5

+0

résultat de isnull (col) sera 1 ou 0, qu'est-ce que vous essayez d'obtenir? – SIDU

Répondre