Reputation: 2074
I'm not sure which framework this is specific to but I think it's Android.
Normally you can use Cursors and ContentValues to do basic queries on tables, but with things like table joins you have to use raw queries as far as I can tell.
But if I am making raw queries than I have to go with the old string concatenation approach which I believe is considered bad practice because you can run into bugs and character-escape issues.
Is there a more robust way to perform join queries?
Upvotes: 0
Views: 63
Reputation: 180240
There is never a need to use string concatenation; rawQuery()
supports parameters, too. (Parameters are passed directly into the database, without having to format them.)
cursor = db.rawQuery("SELECT * FROM a JOIN b USING (id) WHERE name = ?",
new String[]{ name });
Upvotes: 2