• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Search a certain word in a field...

Hi experts,

How to search a certain word in a field of a record?

Field | Title                     | Year |
Data  | Monkey in the blue bottle | 1997 |

I just entered 'blue' and it will come out the above data.
I'm using D3 and MSAccess database.

TQ

iqmedia
0
iqmedia
Asked:
iqmedia
1 Solution
 
kretzschmarCommented:
select * from atable where fieldname like "%TheWord%"
0
 
iqmediaAuthor Commented:
Hi kretzschmar,

You're fast...

Is that all???? shisssss.... OK I'll try it first.

TQ expert.

iqmedia
0
 
iqmediaAuthor Commented:
Hi kretzschmar,

You're fast...

Is that all???? shisssss.... OK I'll try it first.

TQ expert.

iqmedia
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
nestoruaCommented:
HI,
Another method (in this case you don't need to change your
SQL if you use someone):
in the OnFilterRecord event of your TDataset write the following:
Accept:=Pos('blue', Dataset.FieldByName('Title').AsString)>0.
Sincerely,
Nestorua.
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  if you are using Access database, you have to use * instead of %
 your SQL statment will be as:

Select * from urTable where Title like '*blue*'

0
 
kretzschmarCommented:
% does also work with access databases
(via ado tested)

meikl ;-)
0
 
iqmediaAuthor Commented:
Hi experts...

i got stuck yesterday and with these all comment i'll try to do it again... TQ experts.

iqmedia
0
 
iqmediaAuthor Commented:
Hi experts,

I got this error by doing that:
General SQL Error [Microsoft][ODBC Microsoft Access 97 Driver] Expression cannot be used with the LIKE predicate.

but then I change Access 97 to Paradox 7 and do this, and it work:

var wordtofind : string;
begin
  Edit1.Text := wordtofind;
  with Query1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM tableBook');
    SQL.Add('WHERE Title LIKE "%' + wordtofind + '%"');
    Open;
  end;
end;

iqmedia
0
 
iqmediaAuthor Commented:
I think this would be enough.. TQ

iqmedia
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now