Sunday, 20 January 2019

Search In Mysql

Category : MySql
Tutorial kali ini mo mencoba memberikan hal yang lumayan penting untuk membantu user, yaitu pencarian,tujuannya sama seperti artikel aku yang mengunakan lucene, tapi kali ini mengunakan query database secara lansung.

perintah dasarnya kita mengunakan LIKE, contohnya seperti ini :

SELECT id_blog, judul_blog, isi_blog WHERE judul_blog LIKE '%IT%';

pada query di atas memberikan command untuk mencari judul yang mengandung IT (singkatan dari information technology).
yang perlu di perhatikan tanda persennya (%), itu menandakan any character, bila
LIKE '%IT%' -> mencari yang mengandung IT
LIKE 'IT%' ->mencari judul yang berawalan IT
LIKE '%IT'' -> mencari judul yang berakhir IT

nah itu kita sudah bisa membuat search engine
tapi ada masalah bila kita punya judul blog "security", bila kita mencari IT, maka itu akan muncul karena

SELECT "security" LIKE '%IT%' -> TRUE

nah ada cara laen dalam pencarian mysql supaya hanya mencari kata yang kita masukan, bukan bagian dari kata, yaitu mengunakan REGEXP, jadi untuk memperbaiki query di atas kita dapat mengunakan

SELECT id_blog, judul_blog, isi_blog WHERE judul_blog REGEXP '[[:<:]]it[[:>:]]';

itu yang artinya mencari kata IT ,bukan mencari kata yang mengandung huruf IT.
karena :

SELECT "security" REGEXP '[[:<:]]it[[:>:]]' -> FALSE
SELECT "What IT is?" REGEXP '[[:<:]]it[[:>:]]' -> TRUE
thats simple right?

Like this articles? share it with Share With FacebookFacebook
<< Back
0 Comment | 2900 hits | Posted by Callrid at 2007-09-25 16:01:55

Related Read

Add Comment
Name :
Web :
Comment :

Code :

Other Source
A Practical Guide On Complete Multivitamins
Many of us have a hard time deciding what the best multivitamin is for us. This is completely confusing and difficult especially when there are so many bottles to scan in the various aisles of the...

High Blood Pressure
The nutritional benefits of low-fat dairy products are well known for ages. The latest studies show that the ingredients of dairy products - some combination of milk proteins are effective and...

Welcome To - Quality Luxury Replica Vacheron Constantin Watches At Affordable Price
When entering our online store at, you are given an unique opportunity to choose among a wide selection of famous Replica Watches and Replica handbags such as Replica Vacheron...

Ebook Marketing Tips
A great way to have a product to sell on the Internet is an e-book which almost anyone can create. There is no longer any need for delaying with the simple process detailed below. If you are afraid...

Tactical Asset Marketing
Asset Management Different Asset Allocation Strategies Asset marketing is the process of dividing a portfolio into major asset categories such as cash, stocks, real estate, or...

Shout Box
2016-11-24 08:56:05 
Pembicara Internet M
Website yagn bagus
2016-11-24 08:40:45 
Produsen Mukena
Good Website
2016-04-05 20:44:45 
Belanja Alat ukur
Belanja Alat ukur dan Thermal Camera Hanya di
2016-04-04 07:10:03 
hit obat nyamuk
hit obat nyamuk
2016-03-31 15:26:29 
vay dam Lury 2016
We stumbled over here from a different web address and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page yet again.

Site Partners

Search Articles

Web Statistic
No Visitor :
Today Visitor :
Online Visitor :
what is my ip address? Page Rank Checker

< Jan 2019 >

Increase Page Rank

Last Modified 08-November-2011, 23:21:04 pm Created 2006-2012 by Anton Ongsono
All rights reserved