Hi,
I have 2 tables:
A: _ID autoinc primary key
name text
b integer foreign key to table B
B: _ID autoinc primary key
name text
In sql:
CREATE TABLE "A" ("_ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "name"
TEXT, "b" INTEGER NOT NULL DEFAULT '0')
CREATE TABLE "B" ("_ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "name"
TEXT)
I would like to select A records with regards to some criteria, and then B
records matching the A records.
I do not want to make a left join query because,
First, in a concrete example, I may have several relations and this may lead to
a very complex query.
And secondly, the code that reads the result is generated and extracting
records from a single result may be very difficult to implement (I don't event
want to know if it's feasible).
My first idea was to perform:
1) SELECT * FROM A WHERE name LIKE 'foo*'
2) SELECT * FROM B WHERE _ID IN (SELECT _ID FROM A WHERE name LIKE 'foo*')
So my question is:
What is the most efficient to perform such queries ?
Is there any kind of cache that could avoid re-performing the query on A
records ?
Is that the purpose of views ?
Many thanks,
Thomas
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users