Link to home
Start Free TrialLog in
Avatar of jsawicki
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=employeeinfo.LOGNAME
WHERE (((dragon.LastUser) Is Not Null));
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America 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
SOLUTION
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
SOLUTION
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 jsawicki
jsawicki

ASKER

Boag2000, your right i should have posted what code i was using since it worked like a charm using the asterick.  However, when i inputted the % (as seen below) it returned no results.  What is the difference between * and % with the like statement.  

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%"));
in access you will use "*" asterisk in a query

you can use "%" when you are dealing with ADODB recordsets using  VBA codes
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