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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:19:30+00:00 2026-05-22T03:19:30+00:00

Not sure how to title my question… lol. Below is what i am needing.

  • 0

Not sure how to title my question… lol.

Below is what i am needing.


Values in my database look like the following: test_example-1, test_example-2, test_example-TD-1

The values can vary in length, “test_example-” is just an example, some of the values will have varying names.

When i perform a query to grab all the values that look like this “test_example-” i get everything, because i am using the wild card value this way “test_example-%”. However, i do not want the “test_example-TD-1” in the result. I only want the NON-TD values. So, how can i get all the “test_example-” without getting stuff that has more than just a single digit integer after the “-“.

A value in the database will not have anymore than a single digit number (0-9) after the “-“. So basically i need a query that searches for values that would look like this “test_example-[0-9]”.

How can i do that? If this is confusing and needs clarification, please let me know. Thanks!


Here is the exact query that i am doing to ease some confusion:

SELECT MAC, NAME FROM HOST WHERE NAME LIKE (SELECT CONCAT(LEFT(NAME, LENGTH(NAME)-1), "%") FROM HOST WHERE MAC="some mac address");

Here is the working result ( thanks to swati ):

SELECT MAC, NAME FROM HOST WHERE NAME REGEXP CONCAT(LEFT(NAME, LENGTH(NAME)-1), "[0-9]+") AND MAC="some mac address";
  • 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-22T03:19:30+00:00Added an answer on May 22, 2026 at 3:19 am
    SELECT * FROM `foo` WHERE `value` REGEXP "test_example-[:digit:]+"
    

    That should work for test_example-[0-9]. More on Character Classes and REGEXP

    With your given query, it would be:

    SELECT MAC, NAME FROM HOST WHERE NAME REGEXP CONCAT(LEFT(NAME, LENGTH(NAME)-1), "[0-9]+") AND MAC="some mac address"
    

    Note there is an error in your posted query – you have two WHERE clauses.

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

Sidebar

Related Questions

I'm not sure how to title the question I have so I can't be
Not sure if the title is quite right for the question but I can't
Not sure the title fully describes the problem/question I'm trying to ask, sorry. One
Not entirely sure my question title describes what I want to do, but couldn't
The question title is a bit strange because I'm not exactly sure how to
I am not sure how clear my question is by the title, but I
Although the question title appears a bit subjective I am sure there is not
I'm not sure that title conveys my meaning, please change it if you can
I am not sure if the title is accurate. I have several classes like
I'm not sure if the question title is accurate... Let me start by explaining

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.