Solved

search

Posted on 2000-04-08
2
160 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 20 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
binary to char / hexadecimal 5 98
perl match and sort unique result 2 122
perl split by | 2 81
combine multiple lines 2 24
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now