Ricardo Filipe Ricardo Filipe - 21 days ago 11
Android Question

Join two SQLite tables in Android application

I need to join two tables into a relational table. I know that I can do this with inner join but I don't know how to start.

TABLE_SOCIO
-----------------
-id

-name

-phone

-email

TABLE QUOTA
-----------------
-id

-name

-description

-value


Now I need to join this two in on unique table by the id's of each.

RELATIONAL TABLE
-----------------
-id_Quota

-id_Socio


I have one id_Quota to n id's_Socio. It's a relation 1-n. I have an array list with the set of id_Socio that I need to save in relational table with only one id_Quota.

Any ideas? How I can start with inner join? Foreign key it's need?
Any example?

Answer
SELECT  t1.name, t1. phone,
        t2.description, t2.value
FROM    TABLE_SOCIO t1
        INNER JOIN RELATIONALTABLE r ON t1.Id = r.id_Socio
        INNER JOIN TABLE_QUOTA t1 ON t2.Id = r.id_Quota
Comments