Anyone know how to use if statement within a query and has successfully executed in php?
I tried queries like these:
IF NOT EXISTS (SELECT AgentID FROM telecom1.Agents WHERE AgentID='ufo0008') SELECT CompanyName FROM telecom1.Agents WHERE AgentID='ufo0008';
IF 'ufo0008' in (SELECT AgentID FROM telecom1.Agents ) SELECT CompanyName FROM telecom1.Agents WHERE AgentID='ufo0008';
Any query that has If in it dont work for me. The query is excuted fine(mssql_query returns 1) but when pass to function like fetch array it give me an error saying the argument is not a valid resource.
I have post this problem few times in database forum but no one seems to know how to solve it