How do I modify this query in MYSQL?

SELECT title, title REGEXP 'apple' as is_fruit FROM mytable;

TO:

SELECT title, title REGEXP 'apple' or orange...or grapes...as is_fruit...

Basically, how do I do an "OR" for REGEXP?

This question and answers originated from www.stackoverflow.com
Question by (8/2/2010 4:52:06 AM)

Answer

SELECT title, title REGEXP '(apple|orange|...)' as is_fruit FROM mytable;
Answer by

Find More Answers
Related Topics  mysql  database  regex  query
Related Questions
  • How do I do this query in MySQL? (datetime)

    Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime? SELECT ALL where current_datetime - that_datetime < 2500 ...
  • How do I execute this query in MYSQL?

    Suppose I have a column with words: orange grape orange orange apple orange grape banana How do I execute a query to get the top 10 words, as well as their count?
  • How do I write this GROUP BY query in MYSQL?

    Suppose I have a column called "fruits" I want to select all of the top fruits, ranked by fruits (and group by + count). Fruits: orange orange apple banana apple apple In this case, the selec…
  • How do I run this MySQL JOIN query?

    Let's say I have 2 tables. The first table is a list of personas. A user can have many personas. mysql> select id, user_id, name from personas_personas; +----+---------+--------------+ | id…
  • How do I execute this GROUP BY mysql query?

    Suppose I have a table called "Fruits" with a column called "name". name -------- apple orange orange orange apple grape How can I execute a query to produce this: orange 3 apple 2 grape…
  • How do I get PHP variables from this MySQL query?

    I am working on an Asset Database problem using PHP / MySQL. In this script I would like to search my assets by an asset id and have it return all related fields. First I query the database as…
  • How can I optimize this confusingly slow query in MySQL?

    I have a table of blog posts, each with a foreign key back to it's author. There are < 15,000 entries in this table. This query scans over 19,000 rows (per EXPLAIN ), requires a filesort (that mi…
  • How would I do this MySQL query in C#?

    I have 3 tables: KeyWords, GrantsKeyConn, Grants. The way it is set up, each "grant" has associated "keywords", which are stored in the KeyWords table as such: Each "keyword" is associated/co…
  • How would I perform this MySQL Query?

    Suppose I have a table called "approvals". mysql> desc approval; +-------------+------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | …
  • How do I difference time in MySQL query?

    There's a datetime field "time" and it's in Y-m-d H:i:s format. All the values are past values. I need to query that field diffed from current time resulting in seconds. SELECT time FROM table