SQLTeam.com | Weblogs | Forums

Executing SQL statement within MS Access 2010


#1

I am trying to execute SQL statement within Access 2010 with LIKE parameters but its not returning anything.
When use = operator it works fine but returs exact match.
And I want to return rows where CompanyName may have a part of a string,

SELECT [tblSaturdayReport].[Company No], [tblSaturdayReport].[Job Order No] FROM tblSaturdayReport
WHERE [tblSaturdayReport].[Company Name] = 'Accenture';

SELECT [tblSaturdayReport].[Company No], [tblSaturdayReport].[Job Order No] FROM tblSaturdayReport
WHERE [tblSaturdayReport].[Company Name] LIKE '%Acce%';

So my first query works but my second query doesn't return anything at all.
Please help as to what am I missing.
Thanks a lot in advance.


#2

I belive access uses * as wildcard character


#3

tblSaturdayReport.[Company Name]= "Acc"

So I tried this instead of % but this doesn't return anything at all as well.
I mean it doesn't return any error but it doesn't return anything at all.

Basically I trying to return any company name that contains "Acc" .


#4

Is this what you tried?

select [Company No]
      ,[Job Order No]
  from tblSaturdayReport
 where [Company Name] like 'Acce*'
;

#5

Ohh my bad.... yes I typed
tblSaturdayReport.[Company Name]= "Acc"

because I want company name with "Acc" anywhere in between also.
So any number of characters at begibibg and any number of characters in the end as well.

I tried single cotes and double coyes both ' and "


#6

Ohh my bad.... yes I typed
tblSaturdayReport.[Company Name]= "Acc"

because I want company name with "Acc" anywhere in between also.
So any number of characters at begining and any number of characters in the end as well.

I tried single cotes and double cotes both ' and "


#7

trust me completely I twice typed * sign and whenever I post my reply it deletes my * sign.


#8

You have to wrap your code using the </> button, when posting in here.

Does this solve your problem:

select [Company No]
      ,[Job Order No]
  from tblSaturdayReport
 where ucase([Company Name]) like '*ACCE*'
;

#9

Thank you,Thank you and thank you for helping me out.
U r awesome :smile: