Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 替换部分HTML的SQL查询(iframe src=“http://to iframe src=”:/)_Mysql_Sql_Joomla2.5 - Fatal编程技术网

Mysql 替换部分HTML的SQL查询(iframe src=“http://to iframe src=”:/)

Mysql 替换部分HTML的SQL查询(iframe src=“http://to iframe src=”:/),mysql,sql,joomla2.5,Mysql,Sql,Joomla2.5,我有一个Joomla2.5.28,它现在使用https而不是http 一些文章中包含许多来自Vimeo的嵌入式视频 最初,这些视频是使用http嵌入的,所以现在我的数据库中有introtext或fulltext字段,html代码如下: <p>Text, etc...</p> <iframe src="http://player.vimeo.com/video/123" width="690" height="518" frameborder="0" webkitAl

我有一个Joomla2.5.28,它现在使用https而不是http

一些文章中包含许多来自Vimeo的嵌入式视频

最初,这些视频是使用http嵌入的,所以现在我的数据库中有introtext或fulltext字段,html代码如下:

<p>Text, etc...</p>
<iframe src="http://player.vimeo.com/video/123" width="690" height="518" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<iframe width="690" height="400" frameborder="0" scrolling="no" src="https://skydrive.live.com/embed?cid=xxx></iframe>
<ul>
<li>
...
那么,如何构建一个SQL查询来保持HTML的原样,而不是替换:

<iframe src="http://
致:

您可以使用replace函数

mysql> select replace('<iframe src="http://player.vimeo.com/video/123"','<iframe src="http://','<iframe src="://') as replaced ;
+---------------------------------------------+
| replaced                                    |
+---------------------------------------------+
| <iframe src="://player.vimeo.com/video/123" |
+---------------------------------------------+
因此,使用上面的命令,您可以将update命令编写为

update table_name
set field_name = replace(field_name,'<iframe src="http://','<iframe src="://');
您也可以在选择时执行相同的操作

select
replace(field_name,'<iframe src="http://','<iframe src="://') as field_name
from table_name
请参见mysql函数:

SELECT REPLACE('<iframe src="http://player.vimeo.com/video/123" width="690" height="518" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', '<iframe src="http://', '<iframe src="://');

我建议您更新数据库,重写字段,而不是尝试修改select查询,因为您可能会发现性能受到了相当大的影响。。。而不是://。。。我想。
SELECT REPLACE('<iframe src="http://player.vimeo.com/video/123" width="690" height="518" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', '<iframe src="http://', '<iframe src="://');