Doug, on Monday, November 18, 2019 02:48 PM, wrote... > > I'm really confused now. I don't understand the semantics of: > SELECT IfNull('p006', Max(idate)), > IfNull(b, 1), > IfNull(c, 2), > 'y', > IfNull(e, 4), > '2019-20-12' > FROM t > WHERE a = 'p006'; > > versus this: > SELECT (a,b,c,d,e,idate) from t where a = "p006" > > Doesn't the where clause that cannot be satisfied in both cases guarantee > that no rows will > be selected, when there are no records in the database?
Imagine this select: SELECT 'p006',1, 2, 'y', 4, '2019-02-11'; The IfNull is bringing these values back if the 'p006' does not exists. Try the above select in SQLite3 tool. You will get a record. Even without table. Since the original question was how can I INSERT... this will check the table for 'p006', if it exists, it will bring some of the data from that existing record and insert a new one. Ihth. josé _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users