LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-27-2019, 09:29 PM   #16
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled

ok thx

whats the exact command to run the test?
 
Old 10-27-2019, 10:49 PM   #17
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
ok thank you

what is the exact command to run
 
Old 10-27-2019, 11:28 PM   #18
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
ok thank you

what is the exact command to run
See #12
 
Old 10-28-2019, 02:33 AM   #19
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
hey scasey

thank u..

I tried it but it ignore it with no change

Code:
mysql> update streams set stream_source = replace(stream_source, 'live/', '');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1251  Changed: 0  Warnings: 0
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?
 
Old 10-28-2019, 03:31 PM   #20
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
hey scasey,

This what Ive tried



Code:
update streams set stream_source = replace(stream_source, 'live\/', '');
Query OK, 0 rows affected (0.01 sec)
Rows matched: 1302 Changed: 0 Warnings: 0

Code:
update streams set stream_source = replace(stream_source, 'live/', '');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1302 Changed: 0 Warnings: 0

Code:
SELECT replace(stream_source, 'live/', '') FROM stream where stream_source like '%live%';
ERROR 1146 (42S02): Table 'xtream_iptvpro.stream' doesn't exist
update streams set stream_source = replace(stream_source, "live/", '');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1302 Changed: 0 Warnings: 0
 
Old 10-28-2019, 05:46 PM   #21
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
hey scasey,

This what Ive tried



Code:
update streams set stream_source = replace(stream_source, 'live\/', '');
Query OK, 0 rows affected (0.01 sec)
Rows matched: 1302 Changed: 0 Warnings: 0

Code:
update streams set stream_source = replace(stream_source, 'live/', '');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1302 Changed: 0 Warnings: 0

Code:
SELECT replace(stream_source, 'live/', '') FROM stream where stream_source like '%live%';
ERROR 1146 (42S02): Table 'xtream_iptvpro.stream' doesn't exist
Well, that last one doesn't have the right table name in: stream instead of streams Did you correct and re-run with the right table name?

Also, when doing a test like that, I like to output both the before and after pictures, like:
Code:
SELECT stream_source, replace(stream_source, 'live/', '') FROM streams where stream_source like '%live%';
In the attempts without WHERE clauses -- the first two -- the "Rows matched" counts should equal the number of rows in the table. What does
Code:
select count(*) from streams;
return? And
Code:
select count(*) from streams where stream_source like '%live%';
Also
Code:
select stream_source from streams where stream_source like '%live%';
I'm trying to get you to look at the data!
I think one of your trys worked and there are no longer any rows with "live/" in.

And the "Rows matched count" keeps changing. Why?

Last edited by scasey; 10-28-2019 at 05:48 PM.
 
Old 10-29-2019, 02:26 AM   #22
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
Hi

The output was thousands of lines like this

| ["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]



and no I didnt previously successfully replaced, I can view the links in the GUI server and see they are still /live/


like I said I easily replace live and end up with double //

I was hoping I can learn to deal with slashes once and for all.

DM me if u wish to skype. I can let u try yourself and see what works

Last edited by xray55; 10-29-2019 at 02:27 AM.
 
Old 10-29-2019, 02:58 AM   #23
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
Hi

The output was thousands of lines like this

| ["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]

and no I didnt previously successfully replaced, I can view the links in the GUI server and see they are still /live/

like I said I easily replace live and end up with double //

I was hoping I can learn to deal with slashes once and for all.

DM me if u wish to skype. I can let u try yourself and see what works
It's not about slashes! (sorry to yell, but I'm trying to get you to understand)

The data contains escaped slashes...you're trying to match live/ and the string in the database is live\/
so...to test:
Code:
SELECT stream_source, replace(stream_source, 'live\/', '') FROM streams where stream_source like '%live%';
that should yield "thousands of lines" That look like:
Code:
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]  ["http:\/\/domain:9595\/username\/pass\/2030.m3u8"]
can you figure out the update from that?

PS I thought you'd already removed the .m3u8..?
 
Old 10-29-2019, 03:18 AM   #24
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
Code:
mysql> SELECT stream_source, replace(stream_source, 'live/', '') FROM streams where stream_source like '%live%';
302 rows in set (0.00 sec)
The output was tons of lines like this
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]


Code:
mysql> select count(*) from streams;
+----------+
| count(*) |
+----------+
| 1317 |
+----------+
1 row in set (0.00 sec)


Code:
mysql> select stream_source from streams where stream_source like '%live%';
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]



Based on tests and output, my guess for the correct Query


replace(stream_source, '\/live\', '')

or

replace(stream_source, 'live\/', '')

Last edited by xray55; 10-29-2019 at 03:25 AM.
 
Old 10-29-2019, 03:46 AM   #25
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
Code:
mysql> SELECT stream_source, replace(stream_source, 'live/', '') FROM streams where stream_source like '%live%';
302 rows in set (0.00 sec)
The output was tons of lines like this
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]


Code:
mysql> select count(*) from streams;
+----------+
| count(*) |
+----------+
| 1317 |
+----------+
1 row in set (0.00 sec)


Code:
mysql> select stream_source from streams where stream_source like '%live%';
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]

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.

Keep us posted...

Last edited by scasey; 10-29-2019 at 03:49 AM.
 
Old 10-29-2019, 05:34 AM   #26
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
mySql also has a locate function.

What do
Quote:
select locate('live',stream_source)
And
Quote:
Select left(stream_source,locate('live')-1)
And
Quote:
Select concat(left(stream_source,locate('live')-1), right(stream_source,length(stream_source)-left(stream_source,locate('live')-1)-6)
give
 
Old 10-29-2019, 05:51 AM   #27
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
^^ Interesting, but not really relevant to the issue at hand, IMO
The OP is working to modify data in the database.

Last edited by scasey; 10-29-2019 at 05:53 AM.
 
Old 10-29-2019, 06:48 PM   #28
xray55
Member
 
Registered: Aug 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
scasey

I cant get it


Code:
update streams set stream_source = replace(stream_source, 'live\/', '');
Code:
update streams set stream_source = replace(stream_source, '\/live\/', '\/');

Same Output

Code:
mysql> update streams set stream_source = replace(stream_source, '\/live\/', '\/');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1317  Changed: 0  Warnings: 0
 
Old 10-29-2019, 07:27 PM   #29
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by xray55 View Post
Code:
mysql> SELECT stream_source, replace(stream_source, 'live/', '') FROM streams where stream_source like '%live%';
302 rows in set (0.00 sec)
The output was tons of lines like this
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]
The output of this should have been something like
Code:
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"] ["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"]
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%';
That should display 302 rows that look like
Code:
["http:\/\/domain:9595\/live\/username\/pass\/2030.m3u8"] ["http:\/\/domain:9595\/username\/pass\/2030.m3u8"]
Please show us two or three of those rows.

This syntax worked for me. We just have to figure out why it's not working for you.

Last edited by scasey; 10-29-2019 at 07:35 PM.
 
Old 10-29-2019, 07:29 PM   #30
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Oh!
The data you're showing us now still has the .m3u8, in your OP you posted that the replace of the .m3u8 had worked.
Why is it still there?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Slackware vs simple Arch vs simple Frugalware punchy71 Linux - Distributions 2 08-28-2012 02:30 PM
mysql use output of one query in another query secretlydead Programming 2 11-19-2007 01:25 AM
non Recursive query and Recursive query prashsharma Linux - Server 1 06-27-2007 09:33 AM
Database Programming (database to database transaction) johncsl82 Programming 7 02-02-2007 08:20 AM
help with mysql query: return nth rows in query hawarden Programming 2 07-31-2006 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration