开发者

Android SQLite Syntax - IN clause and Subselect

开发者 https://www.devze.com 2023-03-05 17:10 出处:网络
i spend a lot of time of searching a resolution for this query in android. SELECT * FROM positionen WHERE _id IN (SELECT positionenidFROM fahrtenbuch_position WHERE fahrtenbuchid = 2)

i spend a lot of time of searching a resolution for this query in android.

SELECT * FROM positionen WHERE _id IN (SELECT positionenid  FROM fahrtenbuch_position WHERE fahrtenbuchid = 2)

i think im on the wrong way. there are no subselects in android neither开发者_如何转开发 in the rawQuerys nor on the normal querys ? can anyone push me in some direction please ? how do i obtain the _id with some other id's?


I haven't played much with android's sqllite, but I have a feeling this may work for you. instead of :

SELECT * FROM positionen WHERE _id IN (SELECT positionenid  FROM fahrtenbuch_position WHERE fahrtenbuchid = 2)

try

SELECT * FROM positionen p inner join fahrtenbuch_position f on p._id=f.fahrtenbuch_position where fahrtenbuchid = 2

If you're curious about what I just did, read this: http://en.wikipedia.org/wiki/Inner_join#Inner_join

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号