How do I query "begin with" in MySQL?

SELECT stuff REGEXP 'itunes' as is_itunes;

In this MySQL query, if "stuff" has the word "itunes" in it, it will mark it as itunes.

However, I want to say "begin with". How can I check for "begin with" instead of anywhere in the text?

This question and answers originated from www.stackoverflow.com
Question by (11/9/2011 7:17:57 PM)

Answer

SELECT ... WHERE stuff LIKE 'itunes%';
Answer by

Find More Answers
Related Topics  mysql  sql  database  query
Related Questions
  • 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…
  • In mysql how do I find rows repeating with respect to all fields?

    +------------+------------+ | student | department | +------------+------------+ | 1234567890 | CS | | 1234567890 | ME | | 1234567890 | CS | | 000000001 | ME | +------------+---…
  • 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 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 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 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?
  • 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
  • How can I optimize a query that does an ORDER BY on a derived column in MySQL?

    I am having trouble optimizing a relatively simple query involving a GROUP BY, ORDER BY, and LIMIT. The table has just over 300,000 records. Here's the schema (I added some extra indexes to experime…
  • Complicated MySQL Query with distinct

    Here is the table I am getting the data from "actually it's a view of two different tables" The first table is the users table the holds everything about the user. The second is a log table t…