ssblue
asked on
Query not returning blanks
Access - Query is not returning blanks when I use Not Like "Delete"
I should be getting lines with blanks and lines with other text in the field ACTIONTAKEN????????
SELECT tbl_MECHANICAL.TAG_NUMBER, Calendar.MDate, Calendar.MaintenanceID, tbl_MECHANICAL.New_Crafts, tbl_MECHANICAL.Unit, tbl_MECHANICAL.ASSETSDescr iption, tbl_MECHANICAL.Duration, tbl_MECHANICAL.TASKSDescri ptionCorre ction, tbl_MECHANICAL.New_Interva l, tbl_MECHANICAL.Unit, tbl_MECHANICAL.System, tbl_MECHANICAL.Time, tbl_MECHANICAL.ActionTaken
FROM Calendar INNER JOIN tbl_MECHANICAL ON Calendar.MaintenanceID = tbl_MECHANICAL.ID;
I should be getting lines with blanks and lines with other text in the field ACTIONTAKEN????????
SELECT tbl_MECHANICAL.TAG_NUMBER,
FROM Calendar INNER JOIN tbl_MECHANICAL ON Calendar.MaintenanceID = tbl_MECHANICAL.ID;
If Not Like "Delete" will filter out all rows, nothing will be returned. That's by design.
ASKER
In that field there is comments like: "Delete" , "No Action Taken", "ActionTaken
Frequency Revised" , "Change Craft" and then there are blank lines.
I need to see everything except those with "Delete"
How do I get the Blanks and all the other comments??
Frequency Revised" , "Change Craft" and then there are blank lines.
I need to see everything except those with "Delete"
How do I get the Blanks and all the other comments??
Remember, nulls are treated differently. Also realize that "Not Like "Delete" where you don't have any wildcard characters in you comparison string is the same as using <>.
Try something like:
WHERE TRIM(NZ([ACTIONTAKEN?????? ??],""))<> "Delete"
Or
WHERE NOT TRIM(NZ([ACTIONTAKEN?????? ??],"")) LIKE "Delete*" (if you want to filter out those that begin with "Delete".)
Try something like:
WHERE TRIM(NZ([ACTIONTAKEN??????
Or
WHERE NOT TRIM(NZ([ACTIONTAKEN??????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using a left join to see all rows in both tables. Then you can work with a filter on the ActionTaken as some of those rows may be empty.
SELECT tbl_MECHANICAL.TAG_NUMBER, Calendar.MDate, Calendar.MaintenanceID, tbl_MECHANICAL.New_Crafts, tbl_MECHANICAL.Unit, tbl_MECHANICAL.ASSETSDescr iption, tbl_MECHANICAL.Duration, tbl_MECHANICAL.TASKSDescri ptionCorre ction, tbl_MECHANICAL.New_Interva l, tbl_MECHANICAL.Unit, tbl_MECHANICAL.System, tbl_MECHANICAL.Time, tbl_MECHANICAL.ActionTaken
FROM Calendar left JOIN tbl_MECHANICAL ON Calendar.MaintenanceID = tbl_MECHANICAL.ID;
Roger
SELECT tbl_MECHANICAL.TAG_NUMBER,
FROM Calendar left JOIN tbl_MECHANICAL ON Calendar.MaintenanceID = tbl_MECHANICAL.ID;
Roger
ASKER
Thanks for the info
You are welcome!
Gustav,
Why would you use:
Why would you use:
Where tbl_MECHANICAL.ActionTaken Is Null Or Nz(tbl_MECHANICAL.ActionTaken) <> "Delete"
instead of:Where Nz(tbl_MECHANICAL.ActionTaken, "") <> "Delete"
All the solutions are variations of:
WHERE TRIM(NZ([ACTIONTAKEN],"")) <>"Delete"
I thought the field was [ActionTaken???????] from reading the authors post. I didn't pay close attention to the fields in the query.
Let the author pick which one makes sense to him and choose it as the solution, even if it won't compile.
WHERE TRIM(NZ([ACTIONTAKEN],""))
I thought the field was [ActionTaken???????] from reading the authors post. I didn't pay close attention to the fields in the query.
Let the author pick which one makes sense to him and choose it as the solution, even if it won't compile.