parameter searching with wildcards?

G

GiBB

Hello,
I am trying to set up a database to store my cd collection data and im a
little stuck trying to write a query parameter that when i enter my parameter
value it searches for anything with my value in.
E.g. i want to search for song names, i want it so if i put in "song" as my
parameter value in the command prompt, it will find all song names with the
word "song" anywhere in the title.

My SQL at the moment is:

SELECT Songs.[CD Number], Songs.[Track Number], Songs.[Song Title],
Songs.[Album Title], Songs.Artist, Songs.[Music Category]
FROM Songs
WHERE (((Songs.[Song Title]=[Enter Song Name] )));

And i am stuck on where to take this SQL, and knowing me i have made it too
messy to set up how i would like it.
Please help!
 
J

John Spencer (MVP)

Fairly simple, once you know how.


SELECT Songs.[CD Number], Songs.[Track Number], Songs.[Song Title],
Songs.[Album Title], Songs.Artist, Songs.[Music Category]
FROM Songs
WHERE (((Songs.[Song Title]= "*" & [Enter Song Name] & "*" )));

Basically you are concatenating the wild card characters onto the beginning and
end of the parameter input.
 
M

Marshall Barton

GiBB said:
I am trying to set up a database to store my cd collection data and im a
little stuck trying to write a query parameter that when i enter my parameter
value it searches for anything with my value in.
E.g. i want to search for song names, i want it so if i put in "song" as my
parameter value in the command prompt, it will find all song names with the
word "song" anywhere in the title.

My SQL at the moment is:

SELECT Songs.[CD Number], Songs.[Track Number], Songs.[Song Title],
Songs.[Album Title], Songs.Artist, Songs.[Music Category]
FROM Songs
WHERE (((Songs.[Song Title]=[Enter Song Name] )));


WHERE Songs.[Song Title] LIKE "*" & [Enter Song Name] & "*"
 
Top