Assigning a variable to "LIKE" condition search string

pikachew

Registered User.
Local time
Today, 18:52
Joined
Jan 26, 2005
Messages
34
Hi can anyone help me with this query?

'SQLTable "Resolutions Per Year", "SELECT ResName, COUNT(ResName) AS Total FROM Stats LEFT JOIN Resolutions ON (Stats.UserID = Resolutions.UserID AND Stats.ResID=Resolutions.ResID) WHERE Stats.UserId = '"&login&"' AND Date LIKE '%sYear%' GROUP BY Stats.UserID, ResName ORDER BY COUNT(ResName) DESC"

sYear is a variable
example sYear = 2003,2004,2005....

This does not work.
Is there anyway to assign the search string to be a variable?
 
Appears login is a variable also, so why not something like:
WHERE Stats.UserId = '"&login&"' AND YEAR(Date) = "&sYear

But sYear has to contain a single a year and Date has to be definied as a date datatype.
If you have multi-years separated by commas, what about using IN
WHERE Stats.UserId = '"&login&"' AND YEAR(Date) IN ("&sYear&")"

Just a thought
 
Thanks a million FoFa
Your reply has solved my problem...
Posted the question in several forums as i'm new to this forum and didnt know where i would get a reply from. Would restrict my questions to this forum from now onwards...Thanks a lot
 

Users who are viewing this thread

Back
Top Bottom