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.
Just noticed that your OP says “about 235” rows, but this query “matched” 1251 rows — because there is no WHERE clause.
1. You should probably add a WHERE clause so the attempt is only made on rows that you want to change.
2. Are you sure that the first attempt didn’t work?
Based on tests and output, my guess for the correct Query
replace(stream_source, '\/live\', '')
Please use code tags when posting output.
Did you test that? Use the SELECT column, replace(...) syntax. Don’t forget the WHERE clause.
You only want to act on the 302 rows that have “live” in them.
I think you want
Code:
replace(stream_source, ‘live\/, ‘’)
Do you see the difference?
Your guess would remove the escape character from the following slash. I don’t know if that would matter downstream. Maybe. Maybe not.
assuming that the brackets ([]) and quotes are in the data. Are they?
That query should have returned two columns, not just one. Of course it didn't work because the value to match wasn't correct.
Again, you need to show us exactly what the query is returning. We don't need to see all 302 rows, but please copy and past a few lines. It's OK to obfuscate the domain name, but everything else should be as it's printed.
Please do the tests first. By that, I mean the SELECT column,replace(column,'original','replacement'). Please use the WHERE clause.
Showing us the result of the update attempts does not provide any helpful information. It just shows that it didn't work.
The SELECT column, replace(...) WHERE ... will show what's actually happening.
So, the corrected statement to try is
Code:
SELECT stream_source, replace(stream_source, 'live\/', '') FROM streams where stream_source like '%live%';
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.