Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hmmmm.
Post without the long line of ----- perhaps.
Not sure why the output would be messy on the terminal...does it wrap? Why? Is there a longer entry you're not showing us? On my terminal, the space between the pipes appears to be set to the length of the longest entry.
Anyway,
So that didn't work. Is it possible that the data is not what it appears? Maybe the \ or the / are not what they appear to be...not sure how we'd check that. Is there a way to see the string in hexadecimal, I wonder?
Very strange.
I just tried it again, and it works as expected for me. The replace() sees and replaces \/ just fine.
Going to have to tinker with it a bit more.
Try this:
Code:
SELECT stream_source, replace(stream_source, 'live\/', '') FROM streams WHERE stream_source like '%live\/%';
Hmmmm.
Post without the long line of ----- perhaps.
Not sure why the output would be messy on the terminal...does it wrap? Why? Is there a longer entry you're not showing us? On my terminal, the space between the pipes appears to be set to the length of the longest entry.
No, doesnt wrap
Quote:
Originally Posted by scasey
Hmmmm.
Try this:
Code:
SELECT stream_source, replace(stream_source, 'live\/', '') FROM streams WHERE stream_source like '%live\/%';
to see if the \/ is a match...
Code:
mysql> SELECT stream_source, replace(stream_source, 'live\/', '') FROM streams WHERE stream_source like '%live\/%';
Empty set (0.00 sec)
The entire DB is only 25mb
I manually browsed a dump with Ultraedit and found double escapes
TADA!!
Good job xray55. That was a good piece of detective work.
You can mark this thread SOLVED using the Thread Tools at the top of any page.
Hopefully our discussion will help others in the future. It was a strange situation/condition. Makes me wonder where those entries came from. It shouldn't be necessary to escape slashes when writing URLs to a database. It most certainly shouldn't be necessary to store the escape characters.
I do need to escape single quotes when writing names, so that the apostrophe in O'Casey doesn't mess up the insert statement...but the \ doesn't get stored in the database when I do that.
Doesn't matter. It is what it is. Now you know what the data really looks like, and you were able to make the changes you wanted, so task completed.
Like i said, I had easy solutions. I could have easily mass deleted from GUI and reuploaded a corrected list but i wanted to once and for all understand why in this type of DB I can never use the replace command on certain characters.
So to finalize my understanding of escapes? They wrap to ignore a special DB function of that character its wrapping?
Like i said, I had easy solutions. I could have easily mass deleted from GUI and reuploaded a corrected list but i wanted to once and for all understand why in this type of DB I can never use the replace command on certain characters.
So to finalize my understanding of escapes? They wrap to ignore a special DB function of that character its wrapping?
Not sure I understand your question. I can think of no reason to have escapes within the data as you do.
What complicated this was that the data contained an escaped backslash (\\), which rendered as a single backslash when queried, so you couldn't see what to match. So, again, it's not about "certain characters," it is because you didn't know what to match. Once you did, the replace function worked just fine, yes?
The only time I use an escape is when the VALUE of a column delimited by single quotes contains an apostrophe:
Code:
UPDATE table SET name='O\'Hara'
and in that case the backslash does not get written into the data. I do that when I'm creating the SQL statement programmatically. If I were typing it, I could just use double quotes:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.