jsawicki
asked on
Reducing query results by using partial column words
Below is my functional SQL, but every time i try to use the Like function to retrieve results in a field that contain a specific set of words, it returns no data. Fields JOBTITLE & JOBCODE have words that contain APS and CPS and I want to retrieve only those fields. In some instances it is at the beginning and independent whereas other times it is integrated into the name. I thought it could be as simple as adding Like '%APS%' or '%CPS%' but anything i do, the query results are completely empty.
Below are some examples of the data in that field: APS Unit-M, Aps Gen/Fac Inves-M, CVSCPS01, INVCPS10, CPS Investigations
SELECT employeeinfo.LOGNAME, [First_Name] & " " & [Last_Name] AS EmployeeName, dragon.LastUser, dragon.TotalDuration, dragon.TimesRun, employeeinfo.DEPTNAME, employeeinfo.JOBTITLE, employeeinfo.JOBCODE, employeeinfo.REGION
FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName=emplo yeeinfo.LO GNAME
WHERE (((dragon.LastUser) Is Not Null));
Below are some examples of the data in that field: APS Unit-M, Aps Gen/Fac Inves-M, CVSCPS01, INVCPS10, CPS Investigations
SELECT employeeinfo.LOGNAME, [First_Name] & " " & [Last_Name] AS EmployeeName, dragon.LastUser, dragon.TotalDuration, dragon.TimesRun, employeeinfo.DEPTNAME, employeeinfo.JOBTITLE, employeeinfo.JOBCODE, employeeinfo.REGION
FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName=emplo
WHERE (((dragon.LastUser) Is Not Null));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in access you will use "*" asterisk in a query
you can use "%" when you are dealing with ADODB recordsets using VBA codes
you can use "%" when you are dealing with ADODB recordsets using VBA codes
ASKER
Thanks all
% is used in sql server and some other db
* is used in access for same purposes
see: http://www.techonthenet.com/access/queries/like.php
* is used in access for same purposes
see: http://www.techonthenet.com/access/queries/like.php
ASKER
SELECT employeeinfo.LOGNAME, [First_Name] & " " & [Last_Name] AS EmployeeName, dragon.LastUser, dragon.TotalDuration, dragon.TimesRun, employeeinfo.DEPTNAME, employeeinfo.JOBTITLE, employeeinfo.JOBCODE, employeeinfo.REGION
FROM dragon INNER JOIN employeeinfo ON dragon.LastLoginName = employeeinfo.LOGNAME
WHERE (((dragon.LastUser) Is Not Null) AND ((employeeinfo.DEPTNAME) Like "%APS%"));