-
Using LIKE in DAO
I have tried using the like statement in DAO but it does not seem to work with the %
Code:
strSql = _T("SELECT * FROM [TABLE01] WHERE [SME_PIN] = 'PIN01' AND [Event] LIKE 'EVENT01%'");
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, strSql );
this seems to only open the recordsets that match the string exactly with the exception of the '%'. It will not pick up an event named 'EVENT01AA' for example. Is there a specific rule that must be followed for it to work.
-
Maybe this will help...
gg
-
Re: Using LIKE in DAO
Quote:
Originally posted by zMan
I have tried using the like statement in DAO but it does not seem to work with the %
Code:
strSql = _T("SELECT * FROM [TABLE01] WHERE [SME_PIN] = 'PIN01' AND [Event] LIKE 'EVENT01%'");
rs.Open(AFX_DAO_USE_DEFAULT_TYPE, strSql );
this seems to only open the recordsets that match the string exactly with the exception of the '%'. It will not pick up an event named 'EVENT01AA' for example. Is there a specific rule that must be followed for it to work.
Try
LIKE "EVENT01*"
Works on Access
-
DAO using like
I have tried the '*' and it does the same thing. I wonder why the LIKE does not work.
-
Using Like works in DAO
I know this is an old post but I think that it is worthwhile to respond.
I just recently tried using the like statement in a query string and it worked. I don't know why it did not work before. (using dao through c++)
Code:
s = "SELECT * FROM [TABLE01] WHERE ";
s += "[Field01] LIKE '*FZJ*' ";