selecting a record from a table based on column value of another table
I know forming this query is trivial, but I am not able frame the exact
query. Based on what I have read so far, the solution may include joining
two tables. Here is the problem :
TABLE_ONE {S_NO, DK_NO, FRM , DATE}
TABLE_TWO {S_NO, DK_NO , TO}
I want to select a record from TABLE_ONE based on an input value of DK_NO
and value checked for TO field of TABLE_TWO or FRM field of TABLE_ONE
unsuccessful trials so far:
1)
$sql = "select * from TABLE_ONE where DK_NO like '%".$dkno."%' and
(FRM='".$department."' or (daktracker.dakno like '%".$dakno."%' and
daktracker.todeptt='".$department."'))";
2)
$sql = "select * from TABLE_ONE where DK_NO like '%".$dkno."%' and
(FRM='".$department."' or daktracker.todeptt='".$department."')";
No comments:
Post a Comment