Stumped with LIKE query

S

sonicsix

I have a MS Access database (from Office XP) to catalog my movies in. Here's
my dilemma... I have Shrek 1 an 2. From within Access, how can I query the
names so Shrek and Shrek 2 are both returned? I either get one or nothing.
Here's what I have tried (among other things):

SELECT Table1.MovieName, Table1.MovieYear, Table1.Category, Table1.Rating,
Table1.Plot
FROM Table1
WHERE Table1.MovieName Like [Enter Movie Name];

That returns only "Shrek" and not "Shrek 2".
------------------------------------------------------------------------------
-----

SELECT Table1.MovieName, Table1.MovieYear, Table1.Category, Table1.Rating,
Table1.Plot
FROM Table1
WHERE Table1.MovieName Like "%[Enter Movie Name]%";

That returns nothing as it doesn't rpompt me for a partial title name. Any
help?

Thank you very much.
 
J

John Spencer

Either

SELECT Table1.MovieName, Table1.MovieYear, Table1.Category, Table1.Rating,
Table1.Plot
FROM Table1
WHERE Table1.MovieName Like '%' & [Enter Movie Name] & '%'

or

SELECT Table1.MovieName, Table1.MovieYear, Table1.Category, Table1.Rating,
Table1.Plot
FROM Table1
WHERE Table1.MovieName Like "*" & [Enter Movie Name] & "*"

The wild card characters vary depending on which version of SQL you are
using.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
G

Guest

You are getting close but used wrong wildcard --
SELECT Table1.MovieName, Table1.MovieYear, Table1.Category, Table1.Rating,
Table1.Plot
FROM Table1
WHERE Table1.MovieName Like "*"&[Enter Movie Name]&"*";

Use asterisk instead of percent sign.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top