Jump to content

What's wrong with this query?


Moron

Recommended Posts

The situation is that I'm pulling data from three tables. In one of them, I need to specify ONLY a certain year.

 

The query is:

 

$RESULTDS=mssql_query("SELECT DISTINCT M2.[NAMEL], M2.[NAMEF], M2.[NAMEMI], M2.[EMPNO], M2.[MSSNO], M2.[MEMPAD], M2.[MEMPZI], M2.[MEMPCS], M2.[NAMETI], WF.[EMPN], WF.[W2YEAR], WF.[WEMPSX], WF.[WRET],  WF.[EMPWH], WF.[EMPGRS], WF.[EMPFIC], WF.[EMPFGR], WF.[MEDTAX], WF.[FICATX], WF.[TERM], WF.[WTSTAT], WF.[WPYCTR], WF.[EMPUW], WF.[EMPINS], WF.[EMPDC], WF.[EMPPLN], WF.[EMPDR], WF.[EMPDR], FR.[FRAMT], FR.[FYEAR]

FROM MASTERL2 M2

LEFT JOIN W2FILE WF 
ON M2.[EMPNO]= WF.[EMPN]
LEFT JOIN FRINGE FR
ON WF.[EMPN] = FR.[FEMPNO]


WHERE M2.[EMPNO] = '".$_SESSION['empcode']."' 

ORDER BY WF.[EMPN] desc"); 

 

I can echo W2.[W2YEAR] and it comes up as 2008. FR.[FYEAR] does the same, 2008. Then why does FR.[FRAMT] keep pulling the record from 2007?????

 

Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/139896-whats-wrong-with-this-query/
Share on other sites

sorry, I'm not much help because I have no f'n clue where to start reading that query.

I don't see a W2.[W2YEAR] in your query.

 

fill in this list please:

the column name = what is held in this column

MASTERL2.[EMPNO] =

W2FILE.[EMPN] =

FRINGE.[FEMPNO] =

also, what is in $_SESSION['empcode']

 

(these questions may sound stupid, but I just can't seem to figure out what your trying to do here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.