Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5942007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:11:27+00:00 2026-05-22T16:11:27+00:00

I must use this format where A operand B . A is the field;

  • 0

I must use this format where A operand B. A is the field; I want B to be either “text 1” or “text 2”, so if A has data like “text 1 texttext” or “texttext 2” , the query will have result.

But how do I write this? Does MySQL support something like

where A contains ('text 1' OR 'text 2')? `
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:11:27+00:00Added an answer on May 22, 2026 at 4:11 pm

    Two options:

    1. Use the LIKE keyword, along with percent signs in the string

      select * from table where field like '%a%' or field like '%b%'.
      

      (note: If your search string contains percent signs, you’ll need to escape them)

    2. If you’re looking for more a complex combination of strings than you’ve specified in your example, you could regular expressions (regex):

      See the MySQL manual for more on how to use them: http://dev.mysql.com/doc/refman/5.1/en/regexp.html

    Of these, using LIKE is the most usual solution — it’s standard SQL, and in common use. Regex is less commonly used but much more powerful.

    Note that whichever option you go with, you need to be aware of possible performance implications. Searching for sub-strings like this will mean that the query will have to scan the entire table. If you have a large table, this could make for a very slow query, and no amount of indexing is going to help.

    If this is an issue for you, and you’r going to need to search for the same things over and over, you may prefer to do something like adding a flag field to the table which specifies that the string field contains the relevant sub-strings. If you keep this flag field up-to-date when you insert of update a record, you could simply query the flag when you want to search. This can be indexed, and would make your query much much quicker. Whether it’s worth the effort to do that is up to you, it’ll depend on how bad the performance is using LIKE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When must we use this operator by events? What is its usage?
When we must use DebuggerDisplay Attributes? What is the advantage of using this?
Is Firebug lite must needed in Sitecore shell? What is the use of this
Making an adobe flex ui in which data that is calculated must use proprietary
I love challenges like this, I'll hopefully submit my answer soon. Which player has
I have a text file we must process, in the format dd - day
In my company I must use a Bll, Dal and model layer for creating
There is a particular website I must use for work which is absolutely heinous
2 Questions actually: I know i must use Stored Procedures as much as Possible,
On some Microsoft Access queries, I get the following message: Operation must use an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.