Re: How do I browse a database ?
From: Jerry Stuckle <jstucklex_at_attglobal.net>
Date: Mon, 12 Aug 2019 11:49:33 -0400
Message-ID: <qis1qe$5d5$1_at_jstuckle.eternal-september.org>
>
> Agreed. But /not/ having one makes it impossible to add it to the end of a
> selection clause. :-( I've still got to figure out how to handle such
> tables.
>
> ...
>
> After some experimenting it turned out to be embarrassing simple, namely
> this: "LOWER(id)". It causes the values in "id" to be converted to strings
> (supposedly causing the "id" results from the table to be converted into
> strings before sorting too), giving weird end results. I could imagine
> MySQL having the same problem (nudge, nudge .. does it ?)
>
>
> Initially, yes. But I verified (or at least tried to verify) the WHERE usage
> on that webpage I posted the link to.
>
>
> I ment the in-order checking of the comma-seperated equations of the WHERE
> clause, stopping on a non-equal comparision result. A form of an
> implicite AND with a "sudden death" checking termination.
>
> You ofcourse realise that as you say that that doesn't work that way that I
> will, after I got the basic browsing to work, try it out. :-)
>
>
> An expression as mentioned in the WHERE branch of the below image:
>
> https://www.sqlite.org/syntaxdiagrams.html#select-stmt
>
> Below it are a "used by" and "references" list of links, from which I
> selected the "expr" one (duh :-) ). And thats the one I posted. Your
> honor, is that an adequate chain of evidence ? :-) (please do tell if I'm
> wrong there though)
>
> Regards,
> Rudy Wieser
>
>
>
>
>
>
> "Jerry Stuckle" <jstucklex_at_attglobal.net> wrote in message
> news:qipsvu$o0s$1_at_jstuckle.eternal-september.org...
>
>
Date: Mon, 12 Aug 2019 11:49:33 -0400
Message-ID: <qis1qe$5d5$1_at_jstuckle.eternal-september.org>
On 8/12/2019 4:08 AM, R.Wieser wrote:
> Jerry,
>
>> You'll have to look at the table itself. No table *requires* a primary >> key, but it's always a good idea to have one.
>
> Agreed. But /not/ having one makes it impossible to add it to the end of a
> selection clause. :-( I've still got to figure out how to handle such
> tables.
>
>>> Than again, I just ran into this:
> ...
>> Sorry I can't help you here.
>
> After some experimenting it turned out to be embarrassing simple, namely
> this: "LOWER(id)". It causes the values in "id" to be converted to strings
> (supposedly causing the "id" results from the table to be converted into
> strings before sorting too), giving weird end results. I could imagine
> MySQL having the same problem (nudge, nudge .. does it ?)
>
[Quoted] Yes, LOWER() is a string function (converts the string to lower case) so I guess it would return a string if used on a numeric field. But I've never seen a use for that.
[Quoted] >> You may be thinking of the ORDER BY clause, which can use comma separated >> column names.
>
> Initially, yes. But I verified (or at least tried to verify) the WHERE usage
> on that webpage I posted the link to.
>
That's an extension to SQL then. I guess they just use the same parser as for other expressions in the SQL statement.
>> And there is no default sort order in SQL. If you don't specify ORDER BY >> the sort order is undetermined.
>
> I ment the in-order checking of the comma-seperated equations of the WHERE
> clause, stopping on a non-equal comparision result. A form of an
> implicite AND with a "sudden death" checking termination.
>
> You ofcourse realise that as you say that that doesn't work that way that I
> will, after I got the basic browsing to work, try it out. :-)
>
As I said, if it does it is an extension to the SQL standard.
>> That is the definition of an expression, not sort criteria.
>
> An expression as mentioned in the WHERE branch of the below image:
>
> https://www.sqlite.org/syntaxdiagrams.html#select-stmt
>
> Below it are a "used by" and "references" list of links, from which I
> selected the "expr" one (duh :-) ). And thats the one I posted. Your
> honor, is that an adequate chain of evidence ? :-) (please do tell if I'm
> wrong there though)
>
> Regards,
> Rudy Wieser
>
>
>
>
>
>
> "Jerry Stuckle" <jstucklex_at_attglobal.net> wrote in message
> news:qipsvu$o0s$1_at_jstuckle.eternal-september.org...
>> On 8/11/2019 3:04 PM, R.Wieser wrote: >>> Jerry, >>> >>>> You don't use a temporary database. Just use the existing database. I >>>> hope you have a primary key on the table. >>> >>> :-) Thats part of the problem: my program is ment to be a generic >>> viewer, >>> which should be able to handle /any/ sqlite database. And currently >>> I'm >>> not even sure if a sqlite database must actually have a primary key. >>> >> >> You'll have to look at the table itself. No table *requires* a primary >> key, but it's always a good idea to have one. >> >> But I also wouldn't worry too much about using a lot of resources - SQLite >> is good for quick data but not very good at handling large databases. >> Other databases are much more capable. >> >> >>>> You simply add the primary key as the last sort parameter and search for >>>> the next row based on the previous one. >>> >>> Yep, that should work. >>> >>> Than again, I just ran into this: >>> >>> SELECT * FROM foo ORDER BY LOWER(id) LIMIT 7; >>> >>> "id" is the primary key column, an 8 byte integer. >>> >>> Resulting "id"s: 1, 10, 100, 1000, 100000, 10001, 10002 >>> >>> I'm rather sure that all the other key values between 1 and 100002 are in >>> the table too. >>> >>> And when doing this: >>> >>> SELECT * FROM foo WHERE id<='100032' ORDER BY LOWER(id) DESC LIMIT 7; >>> (with or without the quotes around 100032) >>> >>> it thinks that the first number is 99999 (not even 100032 itself!) ... >>> >>> Yep, a string comparision where there should be an integer one. :-( >>> >>> At this moment I really could use a sqlite specific newgroup ... >>> >> >> Sorry I can't help you here. As I said - it's been a LONG time since I've >> used SQLite. Well over a decade at the least. >> >>> >>>> Now the next SELECT gets a little more complicated, but: >>> >>>> WHERE (col1>val1) OR (col1= val1 AND col2>VAL2) OR >>> >>> Whut ? I thought the WHERE comparisions could be seperated by commas, >>> and >>> that the DB software would be smart enough to do the sorting that way by >>> default. >>> >> >> So, if the WHERE clause has multiple conditions they must always use >> boolean operators between the conditions. You may be thinking of the >> ORDER BY clause, which can use comma separated column names. >> >> And there is no default sort order in SQL. If you don't specify ORDER BY >> the sort order is undetermined. >> >>> Looking .... Yup, it looks that I'm right about the expression: >>> https://www.sqlite.org/syntaxdiagrams.html#expr , seventh branch, >>> starting >>> with "(". >>> >> >> That is the definition of an expression, not sort criteria. >> >>> The only thing I have to find out is if the DB software is "smart" >>> enough. >>> >>> >>> ... but first the non-numeric sorting of a numeric column. >>> >>> Regards, >>> Rudy Wieser >>> >>> >> >> >> >> -- >> ================== >> Remove the "x" from my email address >> Jerry Stuckle >> jstucklex_at_attglobal.net >> ==================
>
>
-- ================== Remove the "x" from my email address Jerry Stuckle jstucklex_at_attglobal.net ==================Received on Mon Aug 12 2019 - 17:49:33 CEST