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 ?
search for a word in the database
Moderator: General Moderators
-
PHPForever
- Forum Newbie
- Posts: 14
- Joined: Sun Aug 31, 2008 11:31 am
Re: search for a word in the database
select * from mytable where mycolumn like '%partofthestring%'
Re: search for a word in the database
Moving to Databases. The programming language is irrelevant when you're doing SQL queries.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: search for a word in the database
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:
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')
-
PHPForever
- Forum Newbie
- Posts: 14
- Joined: Sun Aug 31, 2008 11:31 am
Re: search for a word in the database
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.
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.