Wrong flag setting for SUBSTRING_INDEX operator
up vote
0
down vote
favorite
I compiled a query that chooses a link from the 'ss' column:
'ss' column:
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
Here is my SQL:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-3 ),'.jpg" s',1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-2 ),'.jpg" s',1 )
UPDATE post SET still3 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-1 ),'.jpg" s',1 )
I refer to the first link using the -3 flag. When the number of links is three, everything works fine. But when there are fewer of them (there cannot be more than three of them) - an incorrect result is issued. Is there an alternative to the first link? (for cases when links, only 2 for example).
Here is one and non-working options that I went through:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',1 ),'.jpg" s',-1 )
I can not understand why this option does not work.
UPD:
Okey, here is a simple query that I was looking for:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',1 ),'nk"><img data-src="',-1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',2 ),'nk"><img data-src="',-1 )
...
However, I still did not understand the recursive MySQL logic.
mysql
|
show 2 more comments
up vote
0
down vote
favorite
I compiled a query that chooses a link from the 'ss' column:
'ss' column:
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
Here is my SQL:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-3 ),'.jpg" s',1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-2 ),'.jpg" s',1 )
UPDATE post SET still3 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-1 ),'.jpg" s',1 )
I refer to the first link using the -3 flag. When the number of links is three, everything works fine. But when there are fewer of them (there cannot be more than three of them) - an incorrect result is issued. Is there an alternative to the first link? (for cases when links, only 2 for example).
Here is one and non-working options that I went through:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',1 ),'.jpg" s',-1 )
I can not understand why this option does not work.
UPD:
Okey, here is a simple query that I was looking for:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',1 ),'nk"><img data-src="',-1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',2 ),'nk"><img data-src="',-1 )
...
However, I still did not understand the recursive MySQL logic.
mysql
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I compiled a query that chooses a link from the 'ss' column:
'ss' column:
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
Here is my SQL:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-3 ),'.jpg" s',1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-2 ),'.jpg" s',1 )
UPDATE post SET still3 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-1 ),'.jpg" s',1 )
I refer to the first link using the -3 flag. When the number of links is three, everything works fine. But when there are fewer of them (there cannot be more than three of them) - an incorrect result is issued. Is there an alternative to the first link? (for cases when links, only 2 for example).
Here is one and non-working options that I went through:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',1 ),'.jpg" s',-1 )
I can not understand why this option does not work.
UPD:
Okey, here is a simple query that I was looking for:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',1 ),'nk"><img data-src="',-1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',2 ),'nk"><img data-src="',-1 )
...
However, I still did not understand the recursive MySQL logic.
mysql
I compiled a query that chooses a link from the 'ss' column:
'ss' column:
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
<a href="#" target="_blank"><img data-src="https://asd.com/123.jpg" srcset="https://asd.com/234.jpg"></a>
Here is my SQL:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-3 ),'.jpg" s',1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-2 ),'.jpg" s',1 )
UPDATE post SET still3 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',-1 ),'.jpg" s',1 )
I refer to the first link using the -3 flag. When the number of links is three, everything works fine. But when there are fewer of them (there cannot be more than three of them) - an incorrect result is issued. Is there an alternative to the first link? (for cases when links, only 2 for example).
Here is one and non-working options that I went through:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'nk"><img data-src="',1 ),'.jpg" s',-1 )
I can not understand why this option does not work.
UPD:
Okey, here is a simple query that I was looking for:
UPDATE post SET still1 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',1 ),'nk"><img data-src="',-1 )
UPDATE post SET still2 = SUBSTRING_INDEX( SUBSTRING_INDEX( ss,'.jpg" s',2 ),'nk"><img data-src="',-1 )
...
However, I still did not understand the recursive MySQL logic.
mysql
mysql
edited Nov 18 at 8:07
asked Nov 17 at 19:43
noobsaibot
328
328
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18
|
show 2 more comments
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53354897%2fwrong-flag-setting-for-substring-index-operator%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What are you trying to parse from the html? Or what data do you need? i advice you to read Why should I provide an MCVE for what seems to me to be a very simple SQL query?
– Raymond Nijland
Nov 17 at 19:54
I need this link: asd.com/123.jpg in my still1, still2,, still3 columns.
– noobsaibot
Nov 17 at 19:56
The above links are in the database, in the field "xfields"... translation difficulties
– noobsaibot
Nov 17 at 20:05
Why not treat it as xml and extract the data using built in xml handling/xpath?
– Caius Jard
Nov 17 at 20:09
I have not enough experience for this, besides, I am dealing with encrypted IonCube code... A small update of stills1, stills2, stills3 is all I need. I’m sure I’m missing out on some little detail in the SQL request.
– noobsaibot
Nov 17 at 20:18