I am building a performance tracking repository. I have a table of requirements and a table of personnel.
A user selects the person from the personnel list that should have a requirements checklist; the checklist selected is driven by the personnel rank. The personnel table is masterYM, the generic requirements checklist is in refDTGReqtHdr, and the target is the dTGPerfHdr.
To pull this off, I am attempting to use a "Insert Into...Select" query. I have coded what I thought was clean syntax, but get a warning that I have an error in my SQL sntax, specifically, "You have an error in your SQL syntax near 'WHERE masterYM.PrsthdID = refDTGReqtHdr.PrsthdID AND master YM.YMID =' at line 3.
Can anyone identify an issue with the syntax?
mysql_query("INSERT INTO dTGPerfHdr (YMID, EntityID, PrsthdID, SectionID, Required)
SELECT masterYM.YMID, masterYM.EntityID, masterYM.PrsthdID, refDTGReqtHdr.SectionID, refDTGReqtHdr.Required
WHERE masterYM.PrsthdID = refDTGReqtHdr.PrsthdID
AND masterYM.YMID = $HTTP_POST_VARS['YMID']")
or die (mysql_error());
Thanks in advance for the help.