Solved

sql statement issues

Posted on 2014-04-01
3
237 Views
Last Modified: 2014-04-01
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?
0
Comment
Question by:jlcannon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39969510
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

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39969518
NOT x OR NOT y  is not what you want to do, but
NOT ( x OR y )
or
NOT X AND NOT y

this is "purely logic", in code it would look like this:
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 LIKE '%TotalLostMWs%') AND Asset LIKE 'ST201-WCO%';"

Open in new window

0
 

Author Closing Comment

by:jlcannon
ID: 39969544
thank you. I need to think of the NOT as a logic gate in electronics..
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question