Select If
-
- [ offen ]
-
JanausSm -
14. Dezember 2011 um 21:40
-
-
- Offizieller Beitrag
SQLite kennt kein IF.
Du kannst stattdessen alternative Lösungen mit CASE erstellen. Habe ich jedoch auch noch nicht verwendet. Belies dich mal etwas in den SQLite-Websites. -
- Offizieller Beitrag
Ja, klassischer Fall von Case When.
-
[autoit]
#include <Array.au3>
[/autoit]
#include <SQLite.au3>
#include <SQLite.dll.au3>
Global $aresult, $iRows, $iColumns
_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE Data (C_0 VARCHAR(15),C_1 VARCHAR(15),C_2 VARCHAR(15));")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(NULL, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(3, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(4, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(5, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(6, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(7, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(8, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(9, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(10, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(11, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(12, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(13, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(14, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(NULL, 5, 2);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(1, 5, 1);")
_SQLite_Exec(-1, "INSERT INTO Data VALUES(2, 5, 1);")
_SQLite_GetTable2d(-1, "SELECT * FROM Data;", $aresult, $iRows, $iColumns)
_arraydisplay($aresult)
_SQLite_GetTable2d(-1, "SELECT * FROM Data WHERE C_2 = 1 AND (C_0 IN ('1', '2') OR C_0 IS NULL);", $aresult, $iRows, $iColumns)
_arraydisplay($aresult)
_SQLite_Close(-1)Klammersetzung und es geht auch einfacher