[Qt-interest] Breaking down SQL queries
Gabriel M. Beddingfield
gabrbedd at gmail.com
Sat Oct 2 22:07:25 CEST 2010
On Saturday, October 02, 2010 11:04:31 am Anatoly Burakov
wrote:
> I am developing an application that uses SQLite database
> engine. I allow end user to filter the data in a variety
> of different ways, and I'm tired of writing complex
> queries that take up all my screen. Is there a way to
> break down complex queries into simpler ones? Like if i
> query the DB for one filter criteria, then another and
> then intersect the results in order to get what i need?
What about setting up views for frequently used queries?
CREATE VIEW just_foo AS
SELECT foo, bar FROM bars WHERE bat = baz;
CREATE VIEW just_zap AS
SELECT foo, zap FROM zaps WHERE c = x;
SELECT f.foo, z.zap
FROM just_foo AS f, just_zap AS z
WHERE f.foo = z.foo;
I can't remember if SQLite lets you CREATE TEMPORARY VIEW or
not, in case you want 'disposable' views.
-gabriel
More information about the Qt-interest-old
mailing list