COUNT(*) returns NULL if there are no records selected. Change the query like this to accomplish what you're looking for:
SELECT COALESCE(COUNT(*), 0) FROM drzewo_towar WHERE lft > 13 AND rgt < 14 GROUP BY towar;
Thanks! But it's a bit strange - if I remove "GROUP BY" this query (executed using sqlite3_get_table()) returns 0. With "GROUP BY" the number of rows returned by sqlite3_get_table() equals 0 (not 1 with NULL as I expected).
Adam