I have this query and it works well, the question is if there is a way to have the query NULL the column value if it doesn’t exist in the table?
UPDATE PRD_WOCNT
SET c1 = (
SELECT WO_CNT.RATE FROM WO_CNT
WHERE WO_CNT.CNT = PRD_WOCNT.c1
)
WHERE EXISTS (
SELECT WO_CNT.CNT FROM WO_CNT
WHERE WO_CNT.CNT = PRD_WOCNT.c1
)
Right it uses a second table to update the main table values of sales codes into their commission rates. but sometimes a sales code is entered that doesn’t exist in the table so it adds the sales code as a dollar value and makes the added total wrong.
I don’t know too much PHP and trying not to bother with it if I can simply alter the query… it’s a stab in the dark, have a feeling I’ll need to do this on the PHP side but have no idea how I can have my query tell the php it doesn’t exist.
I havn’t executed. I think it will work. Try this query: