简体   繁体   English

SQL选择包含字符串的所有表的所有列的所有行

[英]SQL Select all rows on all columns on all tables that contain a string

I dont really know SQL but have been tasked with importing content to a new WordPress site from an old one. 我真的不懂SQL,但是已经负责将内容从旧网站导入到新的WordPress网站。 All went well bar the internal links have kept the old site url. 一切顺利,内部链接保留了旧网站的网址。 eg post image url is: 例如,发布图片网址为:

www.oldsite.com/content/uploads/01/foo.jpg

instead of 代替

www.newsiteurl.com/content/uploads/01/foo.jpg

I took a look through the DB via phpMyAdmin but could find no direct reference to the old site url - not even in the post's content. 我通过phpMyAdmin浏览了数据库,但找不到直接引用旧站点url的信息,甚至在帖子的内容中也没有。 New links in work fine but Im not about to trudge through 3 years worth of posts replacing urls. 新的链接可以正常工作,但是Im不会花费3年的时间替换url。

Anyone know where this url is set? 有人知道该网址设置在哪里吗? If not how can I search the WP SQL DB for all items of all tables for any cell that contains "oldurl.com"? 如果没有,如何在WP SQL DB中搜索所有表的所有项目,以查找包含“ oldurl.com”的任何单元格?

I already tried 我已经试过了

SELECT * FROM * WHERE * LIKE '%oldurl%'

But phpMyAdmin told me SQL thought I was having it on; 但是phpMyAdmin告诉我SQL认为我正在使用它。 it said #1064 you have an error in your syntax 它说#1064 you have an error in your syntax

You're trying to use WHERE * LIKE something in a SQL statement. 您正在尝试在SQL语句中使用WHERE * LIKE something You Can't Do That??. 你不能那样做? You have to mention the specific column name. 您必须提及特定的列名称。

The fields you're looking for are in the wp_options table. 您要查找的字段在wp_options表中。 They have the option_name s of siteurl and home . 它们具有siteurlhomeoption_name

You really should use the built-in import and export features; 您确实应该使用内置的导入和导出功能。 this business of cloning a site by copying the data tables is somewhat tricky. 通过复制数据表来克隆站点的这项工作有些棘手。

If you're spelunking and trying to figure out what's where, dump the database to an SQL file, then open that file up in a text editor, then search for things. 如果您正在摸索中并尝试找出问题所在,请将数据库转储到SQL文件中,然后在文本编辑器中打开该文件,然后搜索内容。

I used the tool at https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ As suggested by @NathanDawson. 如@NathanDawson所建议,我在https://interconnectit.com/products/search-and-replace-for-wordpress-databases/上使用了该工具。 It's a really neat little plugin that found some entries I'd missed in the post_content table. 这是一个非常简洁的小插件,在post_content表中找到了我错过的一些条目。

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

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