Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Question on how to use OR in a Select statement with where clause (http://www.go4expert.com/forums/question-select-statement-clause-t27803/)

newphpcoder 15Feb2012 14:09

Question on how to use OR in a Select statement with where clause
 
Hi...
I just want to know how can I use OR in my select statement to check if the DATE is equal in NRS table or Reg Att table.
Here is my real code without or to check if the DATE is in NRS not in regatt.
here is my code now:
in this code it works because the data is present in reg_att table
Code:

SELECT em.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME, DATE(a.LOGOUT) AS DATE_DTR, LOGIN AS min_dtr, LOGOUT AS max_dtr FROM hris.personal p, payroll.reg_att a, hris.employment em WHERE DATE(a.LOGOUT) = '2011-12-19' AND p.EMP_ID = '000252' and em.EMP_ID = '000252' AND em.EMP_NO = a.EMP_NO
now that is possible that data is not present in reg_att but possible present in nrs table.
and I tried this:
Code:

SELECT em.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME, DATE(a.LOGOUT) OR DATE(n.TIME_OUT) AS DATE_DTR, a.LOGIN OR n.TIME_IN AS min_dtr, LOGOUT OR TIME_OUT AS max_dtr FROM payroll.nrs n,hris.personal p, payroll.reg_att a, hris.employment em WHERE DATE(a.LOGOUT) OR DATE(n.TIME_OUT) = '2011-12-19' AND p.EMP_ID = '000252' and em.EMP_ID = '000252' AND em.EMP_NO = a.EMP_NO OR em.EMP_NO = n.EMP_NO;
but it did not work.
Thank you

pein87 3Mar2012 12:14

Re: Question on how to use OR in a Select statement with where clause
 
If your checking equivalence use <> instead of = . Each one has its own usages. = is for numbers and <> is for text.


All times are GMT +5.5. The time now is 07:24.