I am trying to create a query that will return all rows from a field that do not contain a word that starts with $. There is a field that contains words such as $System, etc. I can't figure out the proper syntax to get the query to work.
I tried to do that along with a lot of other things and it still returns all the rows containing "$System". I think it has ot do something with the $ and how to bracket it or something.
If you're field is of type 'string' I can't think why cgHoga's solution doesn't work??? Maybe you have leading spaces...which if this is true then alter your code using the Trim function:
SELECT Trim([YourTableName].[YourFieldName]) AS [YourFieldName]
FROM [YourTableName]
WHERE (((Trim([YourTableName].[YourTextName])) Not Like "$*");
I tried the trim function and still not luck. Here is my query if it helps.
SELECT dbo_v_AlarmEventHistory.Area, dbo_v_AlarmEventHistory.Description, Trim([dbo_v_AlarmEventHistory].[Area])
FROM dbo_v_AlarmEventHistory
WHERE (((dbo_v_AlarmEventHistory.Description) Like '*P202*') AND ((Trim([dbo_v_AlarmEventHistory].[Area])) Not Like "$*");
This will essentially only show the first character of 'Area'...where you can then put in criteria to exclude "$"...but first things first...just check that there are certainly text values that start with the dollar symbol ($).
I tried what you suggested and it still did not work
SELECT dbo_v_AlarmEventHistory.Area, dbo_v_AlarmEventHistory.Description, Trim([dbo_v_AlarmEventHistory].[Area])
FROM dbo_v_AlarmEventHistory
WHERE (((dbo_v_AlarmEventHistory.Description) Like '*P202*') AND ((left(Trim([dbo_v_AlarmEventHistory].[Area]),1)) Not Like "$*");
I used this query in SQLServer and it works fine. I am using Access as the front end and linking tables to SQLServer. I tried to just use this query in Access to and the same results.
select area, tagname, description, eventstamp
from v_alarmeventhistory
where area <> '$System'
SELECT dbo_v_AlarmEventHistory.Area, dbo_v_AlarmEventHistory.Description
FROM dbo_v_AlarmEventHistory
WHERE (Mid((dbo_v_AlarmEventHistory.area),(InStr(1,(dbo_v_AlarmEventHistory.area),"$"),1) <> "$"
AND ((dbo_v_AlarmEventHistory.Description) Like '*P202*'));
Any other suggestions?
Thanks for the help. Starting to get frustrated with access.
I feel like I have tried everything. '$*' does not work either. I'm sure that it is some sort of syntax mix up that I can't figure out. Thanks for the help and if anyone has any more tips to try let me know.
SELECT dbo_v_AlarmEventHistory.Area,
dbo_v_AlarmEventHistory.Description
FROM dbo_v_AlarmEventHistory
WHERE dbo_v_AlarmEventHistory.Description Like '*P202*' AND dbo_v_AlarmEventHistory.Area Not Like '[$]*'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.