LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-08-2004, 06:00 AM   #1
gmarais
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.

thanx.
 
Old 03-08-2004, 09:40 AM   #2
elitecodex
Member
 
Registered: Feb 2004
Location: MD
Distribution: Fedora 9
Posts: 129

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

Code:
<?php
$query = "select * from `customerstable` where fieldone LIKE '%" . $criteria . "%' OR fieldtwo LIKE '%" . $criteria . "%'";
?>

Not sure though...

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

Original Poster
Rep: Reputation: 0
thanx

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

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


Reply


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 ChristianNerds.com Programming 4 08-21-2005 02:32 PM
how do I search for multiple filetypes? fisayo Linux - General 4 07-19-2005 07:05 AM
search and copy multiple files NiallC Programming 2 04-29-2005 04:40 AM
Search and Replace over multiple files The_Nerd Linux - Software 8 06-20-2004 06:59 AM
multiple file search llimllib Linux - Software 2 02-10-2003 03:25 AM


All times are GMT -5. The time now is 12:18 AM.

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