I have a table EnginePreference:
CREATE TABLE EnginePreferences (engine TEXT COLLATE NOCASE, databasename TEXT 
COLLATE NOCASE, key TEXT COLLATE NOCASE, value TEXT, groupid INTEGER, 
UNIQUE(engine,databasename,key))

and a table Groups:
CREATE TABLE Groups (groupid INTEGER PRIMARY KEY, groupname TEXT UNIQUE COLLATE 
NOCASE)

I need to select from EnginePreferences replacing groupid with groupname and I 
can do that with:
SELECT engine,groupname,databasename,key,value FROM EnginePreferences left join 
groups on (groups.groupid = EnginePreferences.groupid);

What I really need is ALSO to replace groupname with * if groupid is 0.
Please note that groupid 0 is never written into the Groups table so my 
original query would return NULL as groupname with groupid is 0 instead of the 
required "*".

Any idea?
--
Marco Bambini
http://www.sqlabs.com
http://twitter.com/sqlabs
http://instagram.com/sqlabs



Reply via email to