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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:28:21+00:00 2026-06-16T19:28:21+00:00

I faced a very wierd problem that in my db i set my id

  • 0

I faced a very wierd problem that in my db i set my id as primary key and it stores those ids too that are identical e.g:

+--------+
|   ID   |
+--------+
|  ABC94 |
|  ABC94 |
+--------+

When I deleted them then from phpmyadmin, then it generates following queries for deletion in which you can see one id contains \r which makes its unique but is not visible on select view. Kindly let me know how can i make sure when ids are getting saved then it should only take ABC94 part and ignore any parts like \r or \d or the like . Thanks,

DELETE FROM `Db` WHERE `ID` = 'ABC94\r';
DELETE FROM `DB` WHERE `ID` = 'ABC94';

I tried following code but it gave me error due to \ i guess cause it worked fine when i used - instead of \

SELECT SUBSTRING_INDEX( "ABC94\r",  "\", 1 )
  • 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-16T19:28:24+00:00Added an answer on June 16, 2026 at 7:28 pm

    If there is any possibility of extra white space, you must handle it either in your application code before insert, or trim it off with the RDBMS at INSERT time.

    INSERT INTO `Db` (`ID`) VALUES (TRIM('input value'))
    

    You cannot update your existing rows without key violations unless you devise a scheme of replacing whites pace with other printable characters.

    For example, replace the carriage return characters with x, and they will still be unique:

    /* Global replacement of carriage returns with 'x' */
    UPDATE `Db` SET `ID` = REPLACE(`ID`, '\r', 'x')
    

    http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim

    Your attempt with SUBSTRING_INDEX() was nearly valid, but you should have omitted the backslash and instead supplied the empty string ''.

    SELECT SUBSTRING_INDEX( 'ABC94\r',  '', 1 )
    

    But using TRIM() as I have above is more reliable. If at all possible, the best approach is to fix the source of the input data to avoid generating these in the first place.

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

Sidebar

Related Questions

We were faced with very strange issue that made us crazy. Sometimes newly created
I recently faced a very strange problem. Compilation of our products includes signing the
today I faced with very interesting problem. When I try to rewrite xml file.
I faced a very interesting issue. I'm trying to set the focus on a
One of the problem I faced when using branches in GIT was that it
When trying to recreate an InterpolationFunction produced by NDSolve I faced very strange problem
I faced a problem while using threading for the first time, In an SWT
I faced a problem - I need to use a macro value both as
I faced a problem regarding loading ResourceBundle at server-side on Seam 2.2 application. In
I faced with very very low performance of Java EE (EJB + JSF) application

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.