Best way to select row with following scenario usi

2019-09-17 17:55发布

问题:

I have 3 tables :

    Manager: manager_id, taluka_name  
    Employee: employee_id, employee_manager_id   
    Target: target_id, target_employee_id  

Now i have to show a ListView of all the targets taluka_name wise. I am using greenDao for the interaction with the SQlite database.

This is the process i have tried, It is taking too long using the method i have used:

    Step1: Get Manager ID for the taluka name from the DB.
    Step2: Get Employee for the Target table->Employee ID.
    Step3: Get Manager ID from the Employee table.
    Step4: Compare if Both Manager ID are equal {if YES then target 
           belongs to that taluka}

Below is the type of query i want to accomplish using Greendao

        SELECT *
        FROM target t, location l, current c
        WHERE t.target_location_id = l.location_id
        AND t.target_location_id = c.school_id
        AND t.target_status <> '0'
        AND t.target_status <> '4'
        AND DATEDIFF(NOW(),t.target_exec_end_time)<7