![]() |
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_NOand 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;Thank you |
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:22. |