?
Solved

search queery

Posted on 2005-04-11
10
Medium Priority
?
140 Views
Last Modified: 2010-04-05
I have a field (Actors) that has the names/surnames of the film actors stored.
(on average about 10-15 of them,their names separated by comma)
How can I do a search through that table to find
all the records that have example Marlon Brando inside the Actors field?
What would be the right queery?
Using access db/ADO...
0
Comment
Question by:senad
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13751019
with ADOQuery do
  try
    if active then
      close;
    SQL.Text := 'SELECT * FROM YourTable WHERE Actors LIKE ' + QuotedStr('Marlon');
    Open;
    if RecordCount > 0 then
    begin
      // do what you need here with the record(s)
    end;
  finally
    close;
  end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13751109
mikel...

you just missed the %-signs

SQL.Text := 'SELECT * FROM YourTable WHERE Actors LIKE ' + QuotedStr('%Marlon%');

meikl ;-)
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13751157
ooops he he
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:aikimark
ID: 13752158
meikl,

<<you just missed the %-signs>>
...unless the database is MSAccess.  In that case, the wildcard character is an asterisk (*). :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13752285
hmm, yep, aika, access is special by this, just not thought on this ;-))
0
 
LVL 46

Expert Comment

by:aikimark
ID: 13752848
I assumed MSAccess from "Using access db/ADO" part of original problem description text.  But that might be an incorrect assumption on my part.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13752994
i would read it also in this term, aika:

accessing accessDB through ADO-Connection
-> so the * should be used instead of %
0
 
LVL 22

Author Comment

by:senad
ID: 13759514
what would it look like  if I used edit1.text as parameter?

0
 
LVL 22

Author Comment

by:senad
ID: 13759518
Access accepts % ...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 13759544
>what would it look like  if I used edit1.text as parameter?

build on the fly
  //close before
  SQL.Text := 'SELECT * FROM YourTable WHERE Actors LIKE ' + QuotedStr('*'+edit1.text+'*');
  //* bacause guessing accessDB is used
  //open

with parameter

  //can be set at designtime, must not be changed at runtime
  SQL.Text := 'SELECT * FROM YourTable WHERE Actors LIKE :AValue';
 
  //for search
  //close before
  Dataset.Parameters[0].asString := '*'+edit1.text+'*';
  //* bacause guessing accessDB is used
  //open

just from head, means not tested and typos possible

meikl ;-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question