Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to check the string with the column if the column contains that string or not.

example:String 'how to make pizza' and the column if has 'pizza' i need to fetch that.. like

SELECT * FROM event WHERE ('%how to make pizza%' LIKE EventName);

any idea plz..

share|improve this question
Do you mean SELECT * FROM event WHERE 'how to make pizza' LIKE ('%' || EventName || '%') ; – ypercubeᵀᴹ Jan 4 '13 at 9:38
yeah.. but that returns null.. (column has pizza) – user670619 Jan 4 '13 at 9:40
Does it have 'how to make pizza'? That's what you said (or I thought you did). – ypercubeᵀᴹ Jan 4 '13 at 9:43
i need to compare this string in table's column.. – user670619 Jan 4 '13 at 9:46
SELECT * FROM event WHERE 'how to make pizza' LIKE ('%' || EventName || '%') ; this retruns null – user670619 Jan 4 '13 at 9:46
up vote 3 down vote accepted

You have to take into consideration the Full-Text Search Functions

Full-text searching is performed using MATCH() ... AGAINST syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a string value that is constant during query evaluation. This rules out, for example, a table column because that can differ for each row.

The initial setup and configuration is very simple

share|improve this answer
thank you, i implemented.. – user670619 Jan 4 '13 at 13:14
hi prob is ResultSet reurns nothing,, is it because of In boolean mode... SELECT * FROM event WHERE MATCH (EventName) AGAINST ('how to make pizza' IN BOOLEAN MODE) – user670619 Jan 4 '13 at 14:43

You cannot check for a match against a part of your string. In order to accomplish your duty, you should split your original string. This may be done inside the query itself, provide you write some function that split your text, as explained in . Once you split the string, you may compare every word with your eventname, using the like or = operator.

share|improve this answer

I'm not sure to understand, but if you just want to test if the value exists in the table, just use "EXISTS" and replace * by the ID column.

Else you can use the full text search function : CONTAINSTABLE Here is the documentation :

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.