[sqlite] Simple Sample Code [Linked]

2010-05-31 Thread Gary Briggs
Heya All, I've been a long-time lurker on the irc channel, helping where I can. One question that constantly pops up is "what's the sqlite equivalent of mysql_real_escape_string?" One doesn't like to necessarily answer that particular question as posed, so up until now I've been explaining each t

[sqlite] Creating directed graphs and simple examples

2011-03-15 Thread Gary Briggs
In the interests of itch-scratching, I've created a simple-ish tool to render directed graphs from sqlite databases with foreign keys [using graphviz]. I occasionally see people asking after such things in the sqlite IRC channel. It produces output like this: http://icculus.org/~chunky/stuff/sqlit

[sqlite] Table-valued functions as PIVOT

2017-09-14 Thread Gary Briggs
It's been a while since anyone has brought up PIVOT, and none that I can see since table-valued functions were added [in 3.9.0, I think?] Has anyone successfully implemented PIVOT using table-valued functions? I'm in the situation again where I'd like a better way to pivot, where knowledge of po

[sqlite] Strange concatenation result

2018-02-25 Thread Gary Briggs
Evening I'm seeing a weird effect when concatenting things: WITH q(tape,dp) AS (SELECT '04E', 1) SELECT SUBSTR(tape,1,dp-1) || SUBSTR(tape,dp,1)+1 || SUBSTR(tape,dp+1) AS expect_14E, SUBSTR(tape,1,dp-1) AS segment_1, SUBSTR(tape,dp,1)+1 AS segment_2, SUBSTR(tape,dp+1)

Re: [sqlite] Strange concatenation result

2018-02-25 Thread Gary Briggs
On Mon, Feb 26, 2018 at 12:33:29AM -0500, Igor Tandetnik wrote: > On 2/26/2018 12:23 AM, Gary Briggs wrote: > >Evening > > > >I'm seeing a weird effect when concatenting things: > >WITH q(tape,dp) AS (SELECT '04E', 1) > > SELECT SUBSTR(tape,1,dp-1

[sqlite] BF Interpreter

2018-02-28 Thread Gary Briggs
Thanks to the help the other day with the strange concatentation result. I was referring to a BF interpreter I was working on, in pure SQLite SQL. Well, here it is, working. Hopefully no-one finds this useful, Gary WITH RECURSIVE program AS (SELECT '++[>+++>++>+++>+<<

[sqlite] Correlated subquery throwing an error

2016-02-14 Thread Gary Briggs
I posted a question on stackoverflow, here: http://stackoverflow.com/questions/35382897/implementing-a-sql-query-without-window-functions In short, I have a table that I'm trying to query: CREATE TABLE foo ( id INTEGER PRIMARY KEY, x REAL NOT NULL, y REAL NOT NULL, val REAL NOT NULL,

[sqlite] Correlated subquery throwing an error

2016-02-14 Thread Gary Briggs
; 25 ORDER BY val, DISTANCE(foo.x, foo.y, nearest.x, nearest.y,0) LIMIT 1) AS id2 FROM foo LIMIT 5 Thanks, Gary > Regards > David M Bennett FACS > > Andl - A New Database Language - andl.org > > -Original Message- > From: sqlite-users-bounces at mailinglists.s

[sqlite] Correlated subquery throwing an error

2016-02-14 Thread Gary Briggs
On Sun, Feb 14, 2016 at 07:31:43PM -0500, Richard Hipp wrote: > On 2/14/16, Gary Briggs wrote: > > > > "For every row in that table, I want the entire row in that same table > > within a certain distance [eg 25], with the lowest "val". For rows > >

[sqlite] Correlated subquery throwing an error

2016-02-15 Thread Gary Briggs
On Mon, Feb 15, 2016 at 08:56:35AM +0100, Clemens Ladisch wrote: > Gary Briggs wrote: > >> SELECT > >> a.id AS a_id, > >> (SELECT b.id > >>FROM foo AS b > >>WHERE b.id!=a.id > >> AND distance(a.x,a.y,b.x,b.y)<=25 > &g