 |
| 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
|
|
|
|

October 25th, 2006, 12:19 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

November 1st, 2006, 11:58 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

December 8th, 2006, 01:48 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 8th, 2006, 01:50 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
if it works for u or not ..
do reply me
Success is Never Ending,,Failure is Never Final
|
|

December 8th, 2006, 04:17 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
hai, i use IN,
It is working fine
SELECT * FROM employee
WHERE name IN ('hello')
surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
|
|

December 8th, 2006, 11:02 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thats cool
Success is Never Ending,,Failure is Never Final
|
|

December 22nd, 2006, 12:20 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
gr8 and simple solution to a big prob nice for ya guys
---
Paagle
TEAM LEADER-Team Xuberance( http://www.xuberance.com)
|
|
 |