Re: [sqlite] Column name as a variable

2014-11-20 Thread James K. Lowden
On Tue, 18 Nov 2014 12:06:02 + Simon Slavin wrote: > > my requirement, which is using a > > table name as a variable > > This is deliberately made very difficult in SQL. I think it's for > security reasons. That may be part of it, but It's really all about values. SQL has value semantic

Re: [sqlite] Column name as a variable

2014-11-18 Thread Paul Sanderson
It would have just been a nice elegant solution to a minor problem. Lots of other ways of skinning this cat. Paul www.sandersonforensics.com skype: r3scue193 twitter: @sandersonforens Tel +44 (0)1326 572786 http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit -Forensic Toolk

Re: [sqlite] Column name as a variable

2014-11-18 Thread Simon Slavin
On 18 Nov 2014, at 8:46am, Paul Sanderson wrote: > my requirement, which is using a > table name as a variable This is deliberately made very difficult in SQL. I think it's for security reasons. Simon. ___ sqlite-users mailing list sqlite-users@sql

Re: [sqlite] Column name as a variable

2014-11-18 Thread Paul Sanderson
Thanks all. My requirement was for SQL and unfortunately just the one query. It is also not actually required to get a row count for all tables - that just serves as a good example of my requirement, which is using a table name as a variable. There are plenty of ways around this, but I didn't wan

Re: [sqlite] Column name as a variable

2014-11-17 Thread Keith Medcalf
With the eval() function loaded, sqlite> select tbl_name, eval('select count(*) from ' || tbl_name) from sqlite_master where type='table'; advisory|10 advlink|67528 crew|144809 crewlink|1710151 genre|201 genrlink|703470 lineup|4 map|646 program|447534 role|14 schedule|162272 station|493 mySeries

Re: [sqlite] Column name as a variable

2014-11-17 Thread James K. Lowden
On Mon, 17 Nov 2014 12:00:06 + Hick Gunter wrote: > SELECT table_name FROM sqlite_master; > > And then, in your programming language of choice, execute Or, with some determination, you can do it in two steps in pure SQL: Use SQL to produce SQL, and execute the result, SELECT's

Re: [sqlite] Column name as a variable

2014-11-17 Thread Hick Gunter
SELECT table_name FROM sqlite_master; And then, in your programming language of choice, execute SELECT count() FROM For each received table name. You cannot use a variable instead of a table name in SQL. -Ursprüngliche Nachricht- Von: Paul Sanderson [mailto:sandersonforens...@gmail.co

Re: [sqlite] Column name as a variable

2014-11-17 Thread Paul Sanderson
Thanks Simon I suspected as much - UNION is no good for me, it's easy enough to iterrate through in C. But not really what I was after. Paul www.sandersonforensics.com skype: r3scue193 twitter: @sandersonforens Tel +44 (0)1326 572786 http://sandersonforensics.com/forum/content.php?195-SQLite-Foren

Re: [sqlite] Column name as a variable

2014-11-17 Thread Simon Slavin
On 17 Nov 2014, at 10:55am, Paul Sanderson wrote: > Is it possible to get a row count for each of the tables in a database > using a SQL query. > > i.e. > > is there a way I could use each row in sqlite_master and use > table_name to somehow do a select count(*) from > sqlite.master.table_name