Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
| Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2006, 12:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default all field search

hi,
i know there is a method for my question.
i have a database call employee with name,age,salary,address,telephone fields,
Now i want to search a word "hello", i want to search all the filed and want to return the results, php/mysql
i don't want like
select * from employee where name like '%hello%' or age like '%hello%'
please guide me.
thanks

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
__________________
surendran
(Anything is Possible)
http://www.suren.info
http://ssuren.spaces.msn.com
 
Old November 1st, 2006, 11:58 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

HI Freinds,
I found a solution,
"SELECT * FROM employee WHERE MATCH (name,age,salary,address,telephone) AGAINST ('hello')"

Thanks

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old December 8th, 2006, 01:48 AM
Authorized User
 
Join Date: Nov 2006
Location: Bhopal, MP, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to talk2leo
Default

Hi to use MATCH() AGAINST(), first thing u need to do is, you must have fulltext index on these fields and for fulltext index columns type can be char,varchar,text/blob only.

after doing this if u want that your search should be very clear n apecific i mean if u want to refime ur search which will show exacly what u want then use both MATCH() AGAINST() and Like "%"..if still having problem then query is will be like this

SELECT name,age.......from employee WHERE (MATCH(name) AGAINST('*hello*' IN BOOLEAN MODE) OR MATCH(age) AGAINST('*hello*' IN BOOLEAN MODE)) AND (name like('%hello%') OR age like('%hello%'));

a query like this will refine ur search n will giv u exact serched results..

Regards

Success is Never Ending,,Failure is Never Final
 
Old December 8th, 2006, 01:50 AM
Authorized User
 
Join Date: Nov 2006
Location: Bhopal, MP, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to talk2leo
Default

if it works for u or not ..
do reply me

Success is Never Ending,,Failure is Never Final
 
Old December 8th, 2006, 04:17 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hai, i use IN,
It is working fine

SELECT * FROM employee
WHERE name IN ('hello')

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old December 8th, 2006, 11:02 AM
Authorized User
 
Join Date: Nov 2006
Location: Bhopal, MP, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to talk2leo
Default

thats cool

Success is Never Ending,,Failure is Never Final
 
Old December 22nd, 2006, 12:20 AM
Authorized User
 
Join Date: Dec 2006
Location: Burla, Orissa, India.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to paagle
Default

gr8 and simple solution to a big prob nice for ya guys

---
Paagle
TEAM LEADER-Team Xuberance(http://www.xuberance.com)




Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple field search ddnk77872 PHP Databases 0 May 15th, 2007 02:55 AM
Active Search Field Tachyophan Access VBA 1 January 30th, 2005 01:00 PM
Search Does not go beyond 1st word in field phungleon Classic ASP Databases 2 December 27th, 2004 08:11 PM
How to Search in nTEXT or TEXT field gaupa SQL Server 2000 1 December 21st, 2004 07:48 AM
How do you search datetime field? SoC Classic ASP Basics 6 October 31st, 2004 09:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.