Can someone help me to check whether the SQL
is written in the correct way? I using left-inner join
to join the two tables.
Table Info:id(PK),name,status,date,weather
Table WorkForce: id1(PK), subContractors,noOfPeople,noOfHours,TInfo_id(Refer to Table Info)
Table Info
ID Name Weather Date Status
---------- ---------- ---------- ---------- ----------
1 Paul Sunny 15/10 MC
2 Allen Rainy 15/10 Working
Table WorkForce
ID Subcontractors NumberOfPeople NumberOfHours TInfo_id
---------- -------------- ---------- ---------- -------
1 AAA 2 2 1
2 BBB 3 1 2
Now I want to retrieve all the information based on name
and date
. The information should displayed to textView. However I get nothing display on the editText. How to pass retrieved data to editText?
I wonder whether my SQL
is working fine ?
public void RetrievePage(String name, String date) { //name and date get from previous activity
final String name2 = name;
final String date2 = date;
database = dbHelper.getWritableDatabase();
c = database.rawQuery("SELECT w.Subcontractors, w.NumberOfPerson, w.NumberOfHours FROM Information i LEFT JOIN WorkForce w ON w.TInfo_id = i.ID WHERE i.Name = ? AND i.Date= ? ",
new String[]{String.valueOf(name2),String.valueOf(date2)}, null);
}
Aucun commentaire:
Enregistrer un commentaire