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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:53:14+00:00 2026-05-24T02:53:14+00:00

A few months ago i asked the question below. My question. However, i have

  • 0

A few months ago i asked the question below.

My question.

However, i have ran into a problem.

When i use this query:

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

If the mac address is resolved to “example_224-06-55” and their is another element in the DB named “example_224-06-55-00” they will both show up as a result of this query. I only want “example_224-06-55” to show up as a result of that query.

The size of the name’s will vary, the examples are just examples.

I am having a really hard time figuring this out, any help is greatly appreciated!

THE WORKING QUERY:

SELECT MAC, NAME FROM DB.HOST WHERE NAME REGEXP (SELECT CONCAT(LEFT(NAME, LENGTH(NAME)-1), "[0-9][[:>:]]") FROM DB.HOST WHERE MAC="some mac");
  • 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-24T02:53:16+00:00Added an answer on May 24, 2026 at 2:53 am

    MySQL supports a special word boundary pattern [[:>:]] to solve this.

    SELECT MAC, NAME FROM DB.HOST 
    WHERE NAME REGEXP (
     SELECT CONCAT(LEFT(NAME, LENGTH(NAME)-1), '[0-9]+[[:>:]]') 
     FROM DB.HOST 
     WHERE MAC='some mac'
    );
    

    See http://dev.mysql.com/doc/refman/5.1/en/regexp.html, the word boundary patterns are documented near the bottom of the page.

    ps: Use single-quotes for string literals in SQL. Double-quotes are for delimited identifiers.

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

Sidebar

Related Questions

When I learned MIPS assembly a few months ago, a question popped into my
I only got into PHP a few months ago and have been dabbing into
A few months ago I posted this question because I tried to follow all
I went to the iPhone Developer Tech Talk a few months ago and asked
Few months ago, I have came across a Silverlight tutorial of Eric Cartman (South
I created an Android project a few months ago and now have to automate
I had asked this question in a much more long-winded way a few days
I've asked here a ton of questions about WSAAsyncSelect and NET.Few months ago I
A few months ago I built some online samples like this one from Jeff
I had a similar problem a few months ago, but that was easily solved

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.