简体   繁体   English

从SUBSTRING_INDEX删除字符

[英]Remove characters from SUBSTRING_INDEX

I'm unserialize the data below 我将以下数据反序列化

a:7:{s:12:"existingname";s:0:"";s:12:"originalname";s:50:"165074-mort-de-l-historien-jean-pierre-vernant.jpg";s:3:"alt";s:0:"";s:5:"title";s:0:"";s:4:"desc";s:0:"";s:6:"delete";b:0;s:6:"remove";b:0;}

using this quote 用这个报价

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(value,';',4),':',-1) AS bookimage 
  FROM jksid_flexicontent_fields_item_relations 
 WHERE jksid_flexicontent_fields_item_relations.field_id = 17  
   AND jksid_flexicontent_fields_item_relations.ite m_id = 13153

the result I have is 我得到的结果是

"165074-mort-de-l-historien-jean-pierre-vernant.jpg"

How can I remove the " symbols ? 如何删除"符号?

Try to use replace function. 尝试使用替换功能。
For excample: REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(value,';',4),':',-1), '\\"', '') 例如: REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(value,';',4),':',-1), '\\"', '')

SELECT REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(value,';',4),':',-1),'"','')  AS bookimage 
  FROM jksid_flexicontent_fields_item_relations 
 WHERE jksid_flexicontent_fields_item_relations.field_id = 17  
   AND jksid_flexicontent_fields_item_relations.ite m_id = 13153

I think I stack again 我想我又堆叠了

When I copy it on the quote I've got syntax error 当我在报价单上复制时,出现语法错误

<?php
// get book image
mysql_select_db($database_fsd, $fsd);
$query_wrtbkimg = "
SELECT REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(value,';',4),':',-1),'"','')  AS bookimage 
  FROM jksid_flexicontent_fields_item_relations 
 WHERE jksid_flexicontent_fields_item_relations.field_id = 17  
   AND jksid_flexicontent_fields_item_relations.ite m_id = 13153
";
$wrtbkimg = mysql_query($query_wrtbkimg, $fsd) or die(mysql_error());
$row_wrtbkimg = mysql_fetch_assoc($wrtbkimg);
$totalRows_wrtbkimg = mysql_num_rows($hwrtbkimg);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM