SQLite Forum

SELECT skips empty fields ?
Login
<blockquote>this throws the error "row value misused", which is correct.</blockquote>
My bad : It turns out that I forgot to check directly after the 'prepare' statement.  After I did I got the error you mentioned.

Still, I would have liked to be able to set the sorting direction for a / the total group of columns ...

<blockquote>Are you sure that you don't mean NULL rather than an empty string?</blockquote>
Blimy. Second mistake.  I thought that I had updated the routine to print '<null>' on a NULL ptr. Checking just now shows I had - just not here.  Yes, I get some NULL ptrs back from the <code>sqlite3_column_text</code> function.   

<blockquote>SELECT * FROM moz_places WHERE (title, id) <= (?1, ?9) ORDER BY title desc, id desc LIMIT 34</blockquote>
That was what I, after some trying, ended up with.   After that I thought that the grouping as used in the SELECT might also work with ORDER BY.  The ebsense of an error threw me off. 

<blockquote>Of course, if the value of title or id can be null, then you have to account for that in your select since you can only IS or IS NOT against NULL -- < > = <= >= will always be false.</blockquote>
Did I already mention I'm a novice in regard to sqlite3 ? :-)

I did some more googeling, and found COALESCE.   Which works fine on a string column ("COALESCE(title,'')").  But when I try the same on a numeric column ("COALESCE(visit_count,0)") it returns nothing when I try to go down the list, and gets stuck when I try to go up the list.  For a reason thats as thick as mud to me.   Mind you, without that COALESCE on a numeric column everything seems to work.

I feel like I'm going one step forward, only to be put one step back again. :-| 
:-)

Also, if you have a better way to go at it than using COALESCE I would like to know.

&nbsp;<br>

P.s.
Remarkable that I could post even before receiving and responding to a "did you really want to sign up" confirmation email first.  I would think it would be heavily abused by spammers and other miscreants ...