Issue in Select Statement

Hi…

i had encountered problem in my select statement…

here is my query:


SELECT s.EMP_NO, p.SSS, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME, s.SSSLoan, s.SSSAmor FROM hris.PERSONAL p, hris.employment em, payroll.sssloan s WHERE em.EMP_ID = p.EMP_ID AND em.EMP_NO = s.EMP_NO;

the output of this query is all data in SSSLoan was displayed…I want to display only is the employee that i choose.

Thank you

first of all, i would like to ask you once again to please apply some formatting to your sql statement if you want anybody to read and understand it

SELECT s.EMP_NO
     , p.SSS
     , CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME
     , s.SSSLoan
     , s.SSSAmor 
  FROM hris.PERSONAL p
     , hris.employment em
     , payroll.sssloan s 
 WHERE em.EMP_ID = p.EMP_ID 
   AND em.EMP_NO = s.EMP_NO;

secondly, you should learn to use explicit JOIN syntax, rather than the old style of listing your tables in the FROM clause with the join conditions in the WHERE clause – but the old style still works, so that’s not the problem here

you said “I want to display only is the employee that i choose”

which employee was it that you wanted to see?

The employee that the EMP_ID = $currentEmpID = $_SESSION[‘empID’];

Okay…I will do your suggestion…

I already tried JOIn yet did not work

I already solved it using this:


$sql = "SELECT s.EMP_NO, p.SSS, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME, s.SSSLoan, s.SSSAmor FROM $ADODB_DB.PERSONAL p, $ADODB_DB.employment em, $PAYROLL.sssloan s WHERE em.EMP_ID = '$currentEmpID' AND p.EMP_ID = '$currentEmpID' AND em.EMP_NO = s.EMP_NO";

Thank you

you realize how hard that is to read, right?

i’m not even going to look at it