Satish
Satish

Reputation: 11

How to remove exact match result in MySQL LIKE operator?

Is there any way to remove exact match result from MySQL LIKE operator?

I have a column in a table that contain words like:

  1. Abort
  2. Aborticide
  3. Aborticidium
  4. Abortifacient
  5. Abortion

So, when I query for "Abort", I just want to display related word for "Abort" not exact "Abort". I just want to remove it from result.

I use this simple MySQL query code:

mysqli_query($conn, "SELECT * FROM medi_words WHERE word LIKE '%$query%'");  

Upvotes: 0

Views: 333

Answers (1)

Joseph_J
Joseph_J

Reputation: 3669

You can use another condition in the query like so:

mysqli_query($conn, "SELECT * FROM medi_words WHERE word LIKE '%$query%' AND word != '$query'"); 

Upvotes: 3

Related Questions