How to make INNER JOIN between tables on android Sqlite?

Asked

Viewed 2,211 times

0

I would like to know how to do a more elaborate query using INNER JOIN to join two tables in Sqlite for android. I know how to query using INNER JOIN in Mysql. What I want to know is how to make them in an android application, if it is the same way and if there is no problem.

  • Sql command is a proper language and is adopted as a standard among relational databases.

  • 1

    @Gabriellocalhost, yes but, each vendor creates their own language and AP wants to know how to elaborate a complex query specifically in Sqlite

  • Joins on android are exactly the same as Mysql.... Maybe what you’re talking about are functions, these yes are distinct between Dbms. but with simple queries virtually all banks support with the same writing. If it is the case of some detail function plus its problem.

  • After a lot of trying, I managed to run a query using INNER JOIN on Android Sqlite. I’ll leave it here in case anyone else needs it. Cursor = db.rawQuery("SELECT passeio._id, passeio.pas_duracao, passeio.gui_id, passeio.rot_id FROM passeio INNER JOIN inscriptions ON (passeio._id = inscriptions.pas_id) WHERE inscriptions.tur_id = ?", new String[] { Integer.toString(idTurista) }); Thank you to everyone who helped!

2 answers

0


SELECT t1.columns, t2.columns //campos que você quer visualizar
FROM table1 t1
INNER JOIN table2 t2 on (t1.column = t2.column) //você deve comparar com as chaves das tabelas

Smart to have helped.

Reference

-1

If you use the query() method, which only accepts a single table as an input parameter, you can create a view containing that Join and pass it to the method.

If you use the rawQuery() method, you can create JOIN normally in the SQL string.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.