Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-08-2004, 07:00 AM   #1
LQ Newbie
Registered: Mar 2004
Posts: 11

Rep: Reputation: 0
multiple search on mysql

i have a 'customers' table . what will the sqlquery be to do searches on multiple rows within a table. i.e.

given the 'criteria or part of the word that we are searching for' through a html form, i would like to do a search for anything 'like' the criteria given - results posted to screen and the user can select whatever he wants from that.

Old 03-08-2004, 10:40 AM   #2
Registered: Feb 2004
Location: MD
Distribution: Fedora 9
Posts: 129

Rep: Reputation: 15
Im assuming you are looking for something like this:

$query = "select * from `customerstable` where fieldone LIKE '%" . $criteria . "%' OR fieldtwo LIKE '%" . $criteria . "%'";

Not sure though...

Last edited by elitecodex; 03-08-2004 at 10:42 AM.
Old 03-09-2004, 12:15 AM   #3
LQ Newbie
Registered: Mar 2004
Posts: 11

Original Poster
Rep: Reputation: 0

yip, this looks like it. will give it a try. thanx.
Old 03-10-2004, 09:59 AM   #4
Registered: Nov 2003
Location: Slough, UK
Distribution: Debian
Posts: 146

Rep: Reputation: 15
You can also use regular expressions for a more powerful search:
SELECT * FROM data_table WHERE productName REGEXP "(pen)|(pencil)";


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace with multiple-line strings Programming 4 08-21-2005 03:32 PM
how do I search for multiple filetypes? fisayo Linux - General 4 07-19-2005 08:05 AM
search and copy multiple files NiallC Programming 2 04-29-2005 05:40 AM
Search and Replace over multiple files The_Nerd Linux - Software 8 06-20-2004 07:59 AM
multiple file search llimllib Linux - Software 2 02-10-2003 04:25 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration