-1
Cursor ck = db.rawQuery("select name,title,text,type from abstracts_item,abstract_author,authors_abstract where abstract_author._id == authors_abstract.abstractauthor_id and abstracts_item._id ==  authors_abstract.abstractsitem_id", null);

I was run this same query with other sqlite tool. It works just fine. But, when I try to use with cursor. I got an error

java.lang.IllegalArgumentException: column '_id' does not exist

I got so many solutions. But, nothing worked for me. I will be happy, if you guys help me to solve that.

user2579475
  • 1,051
  • 3
  • 11
  • 20
  • "from abstracts_item,abstract_author,authors_abstract", from clause with 3 tables, is this valid syntax? – kosa Jul 25 '13 at 19:21
  • @Nambari Nope! I'm struggling to understand how this works in "other sqlite tool" without the required joins. – Simon Jul 25 '13 at 19:22
  • It just working fine in adb shell – user2579475 Jul 25 '13 at 19:23
  • 3
    It is valid syntax. It's an implied join. – Benito Bertoli Jul 25 '13 at 19:27
  • @Benito: Thanks! Good to know about this. It seems this technique is not that much popular. – kosa Jul 25 '13 at 19:30
  • 1
    @Benito. Thanks for that. I didn't know that, I assume this is an inner join? I think I prefer an explicit join since the intent is clear. – Simon Jul 25 '13 at 19:31
  • 1
    You are correct. It is valid, yet deprecated. Check out this [answer](http://stackoverflow.com/a/894659/1117415) if you want more details. – Benito Bertoli Jul 25 '13 at 19:38
  • @Benito thanks again, great Q&A you linked - and after reading it, I'm glad that it's being deprecated! I just +1 one of your answers by way of a proper thank you! :) – Simon Jul 25 '13 at 19:48

1 Answers1

0

The SQL language does not use == but rather =.

so it s/b:

Cursor ck = db.rawQuery("select name,title,text,type from
abstracts_item,abstract_author,authors_abstract where abstract_author._id =
authors_abstract.abstractauthor_id and abstracts_item._id =
authors_abstract.abstractsitem_id", null);

You could also increase performance by using inner joins rather that a where clause:

Cursor ck = db.rawQuery("select name,title,text,type from abstracts_item 
    inner join abstract_author on abstract_author._id = authors_abstract.abstractauthor_id
    inner join authors_abstract on abstracts_item._id = authors_abstract.abstractsitem_id", null);
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120