0

I have a table of client contain the client id, name and last name, job ..etc... also I have 16 tables of the grants of client each table contain a different data(different grant) relate with the client by a foreign key of "id"....... for example this is costumer table"clients": enter image description here

and this is an example for an grant of client called order: enter image description here

So when I search for client, I search also for all the grants that he benefited them, and maybe a client can benefit from the same grant more than once........that's means we can find more than one row in the same table relate with the same client:

As you see in the table Of order we have two row relate with the client who have id=2.: So I want to make one query to select all data from the first table and the second of the client "Where id =2"

the problem is how I can get all the information relate with that client and to which row from which table ??

Joseph
  • 11
  • 2

1 Answers1

1

If you want to access data from particular Table you can see the following code It may help you

    public Cursor getInformation(databaseOperations dbo){

    SQLiteDatabase Db = dbo.getReadableDatabase();
    String [] columns = {TableData.TableInfo.USER_NAME, TableData.TableInfo.CONTACT_NO, TableData.TableInfo.EMAIL_ID,TableData.TableInfo.PROFILE_PATH};
    Cursor CR =Db.query(TableData.TableInfo.TABLE_NAME,columns,null,null,null,null,null);
    return CR;
}

If you need data from particular row or column then you can pass different argument instead of null in DB.query. To know about different parameters you can see just this answer click here

I hope it will help you. To know more about parameter details of db.query() function you can go through google search.

Community
  • 1
  • 1
Narendra
  • 125
  • 11
  • I guess my question it's not clear !! what I want is: to select all the information of a client in many tables so I search for it by his id which is a foreign key in these tables ... the problem is how to know which data is from which table in Resultset..how I get it from resultset ?? – Joseph Aug 28 '16 at 21:53