• Resolved smga

    (@smga)


    Hello!
    Are there ways to mass change table contents using database queries? We have a site dedicated to Android car devices, now all devices have switched to version 9.0 and we need to change all the tables here http://www.daystar.su/ves-katalog-golovnyih-ustroystv-daystar-dlya-avtomobiley
    For example, to massively change the content of plain text on pages, we use a query like this: UPDATE wp_posts SET post_content = REPLACE(post_content, 'OLDTEXT', 'NEWTEXT');
    Is there anything for tables?
    Thank!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    That exact query should actually also affect TablePress tables, as they are stored in the wp_posts database table as well.
    You might only have to take into account special characters like quotation marks, if you have those in the old or new text.

    After running this, you should see the change on the tables “Edit” screen already. On the page where the table is shown, it might take up to 12 hours, until the cache is refreshed.

    Regards,
    Tobias

    Thread Starter smga

    (@smga)

    Could you give an example of this request so that it becomes clear to us where to move. Thank in advance!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    I’m not sure that I understand. What do you mean with “request” here? You already have the SQL query which you can use in e.g. PHPMyAdmin.

    Regards,
    Tobias

    Thread Starter smga

    (@smga)

    For example, to change the content of post’s text we use a query like this:
    UPDATE wp_posts SET post_content = REPLACE(post_content, ‘OLDTEXT’, ‘NEWTEXT’);
    For tables of TablePress, of course, we need another query, meaning fields wp_posts and post_content, what I must to write instead of these fields to change TablePress content?
    Thank in advance!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no, as I said above, the exact same query will work for TablePress tables! 🙂

    Regards,
    Tobias

    Thread Starter smga

    (@smga)

    It’s embarrassing for me to bother you, but there are no TablePress data in table wp_posts and column post_content of the database…
    Okay, I’ll try to solve this issue myself, all the best!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    that would be really strange. TablePress stores its tables as a “Custom Post Type” in the wp_posts database table. The table content (a two-dimensional array) is JSON-encoded and then stored in the post_content column. The table name is the post_title. The quickest way to find all tables should be to search for tablepress_table in the post_type column.

    Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Mass change using SQL-queries’ is closed to new replies.