MySQL Forums
Forum List  »  General

Select Susbtr Field
Posted by: Richard Franklin
Date: April 08, 2016 11:52PM

I Have a problem to select a part of characters. Here's my field's content :

[{"index":1,"image":"un-nouveau-test-d-annonce_12_1.jpg","thumbnail":"un-nouveau-test-d-annonce_12_1_t.jpg"}]

I want to select un-nouveau-test-d-annonce_12_1_t.jpg only. But, the name is different in all fields...

field1 : un-nouveau-test-d-annonce_12_1_t.jpg
field2 : hello_ads_2.jpg

So, i want that my "select" select the first letter (u or h) to the end of the address (jpg in all cases).

I have this :

$img ="SELECT
SUBSTR(a.images,
locate('l\":\"',@field)+1, locate('g\"}',@field)-locate('l\":\"',@field)-1)
FROM
base_adsmanager_ads a
" ;

$resultimg = mysql_query($img) or die(mysql_error());
if (mysql_num_rows($resultimg) > 0) {
while ($rowimg = mysql_fetch_array($resultimg)) {
echo $rowimg['images'] ;

} }?>

But the result is empty.

Thanks in advance for your response.

Options: ReplyQuote


Subject
Written By
Posted
Select Susbtr Field
April 08, 2016 11:52PM
April 09, 2016 06:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.