StudioTime
StudioTime

Reputation: 23959

mysql match against wildcard

I have a search facility but want to be able to allow searches of nothing, instead simply listing through categories of items. Pretty standard stuff.

So when a user enters no search term and simply chooses a category, I want my seach to find everything with e.g. "cat_id = 1".

I'm trying the following and I have tried a few different methods but no joy and don't really want to resort to writing different queries for different siutuations if I can help it.

The table I am searching on has a fulltext index on the column named "title" and I'm trying:

select col_name from tablename where (MATCH(title) AGAINST ('*' IN BOOLEAN MODE))

But get no results at all, is this wildcard allowed?

Upvotes: 1

Views: 1088

Answers (1)

Anil Mathew
Anil Mathew

Reputation: 2696

Using * wont help. See the usage from MySQLs site:

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 literal string, not a variable or a column name.

If the user enters no search terms, shouldn't you just omit that particular WHERE condition?

Upvotes: 1

Related Questions