Link to home
Start Free TrialLog in
Avatar of jlcannon
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?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

NOT x OR NOT y is not what you want to do, but a NOT (x OR y)
this is "purely logic", see how this would look like in the code:
sql = "SELECT * FROM tblData 
where NOT (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 NOT '%TotalLostMWs%') 
AND Asset LIKE 'ST201-WCO%';"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jlcannon
jlcannon

ASKER

thank you. I need to think of the NOT as a logic gate in electronics..