jlcannon
asked on
sql statement issues
I am pulling data to a web page from a named range in excel. the named range is called tblData. On my page I have two tables. the first table is populated via the following sql statement:
***************
sql = "SELECT * FROM tblData where (TagName LIKE '%Throttle_PctMax%' OR TagName LIKE '%Section1_IsenEff%' OR TagName LIKE '%Section2_IsenEff%' OR TagName LIKE '%Section3_IsenEff%' OR TagName LIKE '%Section4_IsenEff%' OR TagName LIKE '%WtPctLiqInExh%' OR TagName LIKE '%TotalLostMWs%') AND Asset LIKE '%ST201-WCO%';"
****************
and it works exactly like I want it to. the second table i want to exclude all the stuff from the table 1 so i used the following sql statement:
****************
sql = "SELECT * FROM tblData where (TagName NOT LIKE '%Throttle_PctMax%' OR TagName NOT LIKE '%Section1_IsenEff%' OR TagName NOT LIKE '%Section2_IsenEff%' OR TagName NOT LIKE '%Section3_IsenEff%' OR TagName NOT LIKE '%Section4_IsenEff%' OR TagName NOT LIKE '%WtPctLiqInExh%' OR TagName NOT LIKE '%TotalLostMWs%') AND Asset LIKE 'ST201-WCO%';"
*****************
and that returns everything including the stuff from table 1.
what am i doing wrong?
***************
sql = "SELECT * FROM tblData where (TagName LIKE '%Throttle_PctMax%' OR TagName LIKE '%Section1_IsenEff%' OR TagName LIKE '%Section2_IsenEff%' OR TagName LIKE '%Section3_IsenEff%' OR TagName LIKE '%Section4_IsenEff%' OR TagName LIKE '%WtPctLiqInExh%' OR TagName LIKE '%TotalLostMWs%') AND Asset LIKE '%ST201-WCO%';"
****************
and it works exactly like I want it to. the second table i want to exclude all the stuff from the table 1 so i used the following sql statement:
****************
sql = "SELECT * FROM tblData where (TagName NOT LIKE '%Throttle_PctMax%' OR TagName NOT LIKE '%Section1_IsenEff%' OR TagName NOT LIKE '%Section2_IsenEff%' OR TagName NOT LIKE '%Section3_IsenEff%' OR TagName NOT LIKE '%Section4_IsenEff%' OR TagName NOT LIKE '%WtPctLiqInExh%' OR TagName NOT LIKE '%TotalLostMWs%') AND Asset LIKE 'ST201-WCO%';"
*****************
and that returns everything including the stuff from table 1.
what am i doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you. I need to think of the NOT as a logic gate in electronics..
this is "purely logic", see how this would look like in the code:
Open in new window