Checking in mysql database the data before compute the deduction

i could not join them because the first table has only data that i need to get the deduction and no need to put an employee id on that…so theres no fields that they both have…so i could not join them…

i only want is to work my condition…my problem is cin my query, only the first row executed.

Thank you

I used this query:


$sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; 

I need to used EMP_ID in where clause to check if who’s employee should have that total earnings.

My problem is how can i get the data to check the range of totearn and get the employeeshare.

Thank you so much…

I’m sorry im not too good in mysql query…

I used this query:


$sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID'"; 

I need to used EMP_ID in where clause to check if who’s employee should have that total earnings.

My problem is how can i get the data to check the range of totearn and get the employeeshare.

Thank you so much…

I’m sorry im not too good in mysql query…


WHERE em.EMP_ID = '$currentEmpID'
[B][COLOR="#FF0000"]AND $amount BETWEEN From_Range AND To_Range[/COLOR][/B]

Thank you for your suggested codes…

it works

this is my new code:


$sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range";
$rs = $conn2->Execute($sql);

That’s good to hear.
Do you understand how it works?

yes, you do –

FROM $PAYROLL.sss
   , $ADODB_DB.employment em 

you also have a WHERE clause which restricts the employment table so that it returns only rows for $currentEmpID, but this row (or rows!) is then joined with every single row in the sss table

this may be what you intended, but we can’t tell, because you did not explain anything about your tables

like i said before, you should test your queries outside of php first, to ensure they are producing exactly what you want

I used this code and it works…


$sql = "SELECT Ref_No, From_Range, To_Range, Employee_Share FROM $PAYROLL.sss, $ADODB_DB.employment em WHERE em.EMP_ID = '$currentEmpID' AND $TotEarn BETWEEN From_Range AND To_Range";
$rs = $conn2->Execute($sql);