Difference between revisions of "NULLIF/de"
From SQLZOO
< NULLIF
(Created page with "Category:Deutsch <table align='right' border='1'> <caption>Kompatibilität</caption> <tr><th colspan='3'>NULLIF(f1,f2)</th></tr> <tr><td align='center'>'''DBMS'''</td><td ...") |
|||
| Line 15: | Line 15: | ||
<p></p> | <p></p> | ||
<pre style='width:60ex'> | <pre style='width:60ex'> | ||
| − | NULLIF(x,y) = NULL | + | NULLIF(x,y) = NULL, wenn x = y |
| − | NULLIF(x,y) = x | + | NULLIF(x,y) = x, wenn x != y |
</pre> | </pre> | ||
Latest revision as of 11:48, 28 October 2012
| NULLIF(f1,f2) | ||
|---|---|---|
| DBMS | OK | Alternative |
| Ingres | Ja | |
| MySQL | Ja | |
| Oracle | Ja | |
| PostgreSQL | Ja | |
| SQL Server | Ja | |
NULLIF
NULLIF liefert NULL, wenn beide Argumente gleich sind, sondt wird das erste Argument zurückgegeben.
NULLIF(x,y) = NULL, wenn x = y NULLIF(x,y) = x, wenn x != y
Mit NULLIF kann bspw. ein bestimmter Wert durch einen NULL-Wert ersetzt werden. In diesem Beispiel wird ein Wert der Spalte party (Partei) durch einen NULL-Wert ersetzt, wenn er den Wert 'Lab' (Scottish Labour) enthält.
SELECT name, party ,NULLIF(party,'Lab') AS aff FROM gisq.msp WHERE name LIKE 'C%'
SELECT name, party ,NULLIF(party,'Lab') AS aff FROM msp WHERE name LIKE 'C%'
Siehe auch
| Sprache: | English • Deutsch |
|---|