Page 1 of 1
search for a word in the database
Posted: Wed Jan 28, 2009 4:03 pm
by PHPForever
I think this is more of a sql question than a php one but since my application is in php, I just thought I'd ask it here.
I'm trying to find occurences of a string in my database. Is there a way to do that ?
Re: search for a word in the database
Posted: Wed Jan 28, 2009 9:16 pm
by yacahuma
select * from mytable where mycolumn like '%partofthestring%'
Re: search for a word in the database
Posted: Thu Jan 29, 2009 10:04 am
by pickle
Moving to Databases. The programming language is irrelevant when you're doing SQL queries.
Re: search for a word in the database
Posted: Thu Jan 29, 2009 10:44 am
by Attero
You should have a look at using the SQL function, LIKE.
You would find it a lot easier to use MATCH() AGAINST() in fulltext searches.
Look up MATCH() AGAINST() for MySQL in google.
You will need to make sure you know how to make fulltext catalogs in MySQL.
It's as easy as going:
Code: Select all
SELECT * FROM TABLE
WHERE MATCH(field1, field2, field3) AGAINST('search goes here')
Re: search for a word in the database
Posted: Mon Feb 23, 2009 3:01 pm
by PHPForever
I was looking to search the database and not the table. Thanks though.
I found that phpMyAdmin has an UI interface which lets you to view the databases and also allows you to search for a string in the entire database.