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

  • Home
  • SEARCH
  • 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 7159233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:11:48+00:00 2026-05-28T13:11:48+00:00

I have a query I need to run on almost 2000 strings where it

  • 0

I have a query I need to run on almost 2000 strings where it would be very helpful to be able to do a list like you can with the “IN” operator but using the LIKE comparison operation.

For example I want to check to see if pet_name is like any of these (but not exact): barfy, max, whiskers, champ, big-D, Big D, Sally

Using like it wouldn’t be case sensitive and it can also have an underscore instead of a dash. Or a space. It will be a huge pain in the ass to write a large series of OR operators. I am running this on MySQL 5.1.

In my particular case I am looking for file names where the differences are usually a dash or an underscore where the opposite would be.

  • 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-28T13:11:49+00:00Added an answer on May 28, 2026 at 1:11 pm

    You could do something like this –

    SELECT FIND_IN_SET(
      'bigD',
       REPLACE(REPLACE('barfy,max,whiskers,champ,big-D,Big D,Sally', '-', ''), ' ', '')
      ) has_petname;
    +-------------+
    | has_petname |
    +-------------+
    |           5 |
    +-------------+
    

    It will give a non-zero value (>0) if there is a pet_name we are looking for.

    But I’d suggest you to create a table petnames and use SOUNDS LIKE function to compare names, in this case ‘bigD’ will be equal to ‘big-D’, e.g.:

    SELECT 'bigD' SOUNDS LIKE 'big-D';
    +---------------------------+
    | 'bigD'SOUNDS LIKE 'big-D' |
    +---------------------------+
    |                         1 |
    +---------------------------+
    

    Example:

    CREATE TABLE petnames(name VARCHAR(40));
    INSERT INTO petnames VALUES
      ('barfy'),('max'),('whiskers'),('champ'),('big-D'),('Big D'),('Sally');
    
    SELECT name FROM petnames WHERE 'bigD' SOUNDS LIKE name;
    +-------+
    | name  |
    +-------+
    | big-D |
    | Big D |
    +-------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a query which list all the user according to the
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have a query: SELECT ID FROM requests WHERE date <operator> <expression> I need
I have a raw sql query I need to run, but the database name
So, I have a huge query that I need to run on an Access
I have a reasonably long SQL query that I need to run in a
I need to run query called MyQuery that I have in Access that makes
I have a Mysql insert query. I need to run the query everyday, at
Hi I have a query that I have run with MySql and I need
I have 2 tables from which i need to run a query to display

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.