Thursday, July 28, 2005

don't forget ( and ) in sql query if using both AND & OR

//--------------- correct query
strSQL = "select download_agent from afc.agent where download_agent=agent_nbr and Agent_type='D' and download_agent = '"& sessiondata("strAgencyCode") &"' and (COMM_PRODUCTS = 'V' or COMM_PRODUCTS = 'A') with ur"

//incorrect query
strSQL = "select download_agent from afc.agent where download_agent=agent_nbr and Agent_type='D' and download_agent = '"& sessiondata("strAgencyCode") &"' and COMM_PRODUCTS = 'V' or COMM_PRODUCTS = 'A' with ur"

No comments: