Jason Tudor wrote:
>
> In order to get the count from a particular table, I could do the following:
>
> SELECT COUNT id FROM main.table UNION
> SELECT COUNT id FROM db2.table
>
> I would then step through the result and add the two values to get a total
> count.
That would not be the optimal use in this case, programmatically 
(speed-wise is another story). However, you can nest that in a larger query:

SELECT sum(cid) FROM
(SELECT COUNT(id) as cid FROM main.table
UNION
SELECT COUNT(id) as cid FROM db2.table)


Which would yield one result only.

My basic rule is if I need to put the two in relation together (join, 
union, etc), I attach them. If not, I make more connections.

Martin
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to