?
Solved

search

Posted on 2000-04-08
2
Medium Priority
?
170 Views
Last Modified: 2010-03-05
hi experts,

I am writing a search engine for my database. i am using MySQL, and using Perl dbi.
how can i write SQL statement so that it will check each field for the string?

i only know to check only one field like:
select * from table_name where name=$search_string

but i want to check not only the name field, but all the fields in that table.
thanks.

Stanley
0
Comment
Question by:stanleyhuen
2 Comments
 
LVL 2

Accepted Solution

by:
tpryor earned 80 total points
ID: 2697842
well if the data is all in the same table
you need to append to your where clause.

like so...

select * from table_name where name=$search_string || field_name2=$search_string || field_name3=$search_string etc...

if the data is across multible tables
you must prefix the table name using dot notation to the field name

select * from table_name where name=$search_string || table_name.field_name2=$search_string || table_name.field_name3=$search_string etc...


You could keep this information ( the table and field names ) in arrays for eassier management and execution of the querries.

gl
t
0
 

Author Comment

by:stanleyhuen
ID: 2700837
how can I  keep the information ( the table and field names ) in arrays for eassier management and execution of the querries?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

862 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