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 (TABLE_TWO.DK_NO like '%".$dakno."%' and TABLE_TWO.TO='".$department."'))";
2)
$sql = "select * from TABLE_ONE where DK_NO like '%".$dkno."%' and (FRM='".$department."' or TABLE_TWO.TO='".$department."')";