• I want to delete from:

    the table called wp_options,

    only the rows where the column “option_name” contains the word “_wp_session_” (not necessarily equal, but contains that),

    and with the column “option_id” between 5000 and 10000

    How can I write this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    DELETE FROM wp_options where option_name LIKE '%_wp_session_%' AND option_ID BETWEEN '5000' AND '10000';

    Thread Starter ketanco

    (@ketanco)

    It didnt do anything

    Just in case I did a search query with same criteria and it generated the following code:

    SELECT * FROM wp_options WHERE option_id BETWEEN 5000 AND 10000 AND option_name LIKE ‘%_wp_session_%’

    But when I replaced select with delete it gave syntax error.
    But if I try yours, it doesnt do anything. May be the % after wp session should be added to yours?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    ‘DELETE’, not ‘DELETE *’.

    Thread Starter ketanco

    (@ketanco)

    Ok so I used
    DELETE from wp_options where option_name like “%_wp_session_%” and option_id between 5000 and 10000

    and it works.

    the first time i did deletion, i deleted only about 500 rows (my numbers were different than 5000 and 10000) and then i checked the total number of rows of table and it indeed went down by 500

    but then i deleted about 2500 rows but the total number of rows of table ent down by only few hundred. although it said 2500 rows affected by my deletion. how can this be?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I don’t know. This is no longer, if it ever was, a WordPress question. You may want to check the MySQL support forums for expert advice.

    Thread Starter ketanco

    (@ketanco)

    Yes you are right, it just started here because it was wordpress site. I am figuring this out separately thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to delete these rows?’ is closed to new replies.