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 9165897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:01:07+00:00 2026-06-17T15:01:07+00:00

I am glad if any one could help me out here. I have a

  • 0

I am glad if any one could help me out here.

I have a table Table1 and column XXXXXX with the data as following

XXXXXX
---------
1
2
1
2
x_y
A_12
3
12345_abcd

I want the output as

XXXXXX
---------
1
2
3

I have tried the following query

select DISTINCT XXXXXX from Table1 where XXXXXX NOT LIKE '%_%';

Also tried SELECT DISTINCT XXXXXX FROM Table1 WHERE CHAR ('_','XXXXXX')=0;

The above query is fetching everything from the table. Can anyone help me on this issue.

  • 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-06-17T15:01:08+00:00Added an answer on June 17, 2026 at 3:01 pm

    Try:

    WHERE  XXXXXX NOT LIKE '%\\_%' ESCAPE '\\' 
    

    The “escape” character is what tells MySQL that the underscore is to be interpreted as literal underscore character, and not a wildcard. (In the LIKE expression, an underscore (_) is a wildcard that matches any single character, just as the percent (%) is a wildcard that matches zero, one or more characters.

    Note that other characters can be used as the escape character; it doesn’t have to be the backslash. The backslash is itself an escape character in MySQL, so have a backslash recognized as the escape character for the LIKE, we have to use double backslashes “\\“. That makes MySQL recognize this as a single backslash character.

    As an example, we can use the carat “^” character as the escape character, like this:

    WHERE  XXXXXX NOT LIKE '%^_%' ESCAPE '^'
    

    Similarly, the escape character can be used to search for a literal percent sign % using a LIKE operator like this:

    WHERE foo LIKE '%\\%%' ESCAPE '\\'
    

    (That will search for an occurrence of a percent sign character in foo.)


    As an alternative to the NOT LIKE operator, we can use the ‘NOT REGEXP’ operator to exclude rows where foo contains an underscore character, like this:

    WHERE foo NOT REGEXP '_'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hittig my head on this and i will be glad for any help.
I'm looking to learn some theory about data/audio/video compression, and would be glad to
I don't have even any idea how to do this and the documentation of
This could probably be generalized to any templated class, but I've run into this
I have a menu that asks for the user to pick one of the
I am having a problem with Regex (yes, again, one day I have to
I have a testing server which runs headless. One test I want is to
Hi I have a form that data post something weird... HTML: <form> <input type=radio
I have a javascript object which I am encoding to Json and sending data
I have a large (~2.5M records) data base of image metadata. Each record represents

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.