Hire PHP Web Developer
Following example will retrive all the records from table that have 'music' word in emp_info colomn.
Query will avoid emp_id = 4 bcoz its not has 'music' only. its 'musics' in value.
There are 3 ways, you can get result from databse.
Lets assume we have following table :
table : emp_info
CREATE TABLE
emp_info (
emp_id INT UNSIGNED NOT NULL PRIMARY KEY,
emp_name VARCHAR(200),
emp_info TEXT,
FULLTEXT (emp_info)
);
Insert following rows into table :
emp_id emp_name emp_info
=============================================================================
1 Rocky i love to sing a song
2 Andy i want to become a singer
3 Jackson i am music lover
4 Neil i don't like musics
5 Williem sometime i enjoy music
6 Helly i love music all day
query1 => SELECT emp_id FROM emp_info WHERE emp_info like '% music %'
query2 => SELECT emp_id FROM emp_info WHERE MATCH (emp_info) AGAINST('music')
query3 => SELECT emp_id FROM emp_info WHERE emp_info REGEXP '[[:<:]]music[[:>:]]' =1
Output of all query:
emp_id :
3
5
6
contact : iamvasim@gmail.com

0 comments:
Post a Comment