sql - SELECT statement to select from multiple tables referenced by ROWIDs -
i have small sqlite 3 database accessed autoit. works great, need more complex statement , maybe regret have referenced tables using rowid instead of particular id fields...
this configuration:
table 1 person name (string) initials (string) table 2 projekte description (string) person (containing rowid of table person) table 3 planungen projid (contains rowid of table projekte) plid (numeric, main selection identifier) (plus other fields not matter)
initially, needed read data table 3 planungen filtered specific plid. did using:
select rowid,* planungen plid=[filtervalue1] order rowid;
works great.
now, need select subset of these records, plid=[filtervalue1] , projid points table 2 projekte entry, complies projekte.person=[filtervalue2]. not need table 1 (person), 2 , 3.
i thought way (now becomes obvious, sql idiot):
select rowid,* planungen p, projekte pj pj.person=[filtervalue2] , p.projid=pj.rowid , p.plid=[filtervalue1] order rowid;
that runs sqlite error telling me there no such column rowid. oops! really? how can be? can't use rowid in clause?? well, won't intent anyway.
can please me? can done without changing database structure , introducing id fields?
it great if output of select identical first, working select command, additional "filtering" applied.
you should add proper integer primary key column tables. (the implicit rowid
might changed vacuum.)
anyway, query fails because column name rowid
ambiguous. replace pj.rowid
(or whatever table want access).
Comments
Post a Comment