Search

Content

Some useful Mysql commands7/04/2016

1. Select and insert to antohter table.

INSERT INTO wp_posts_main (
post_author,
post_date,post_date_gmt,
post_content,post_title,
post_excerpt,post_status,
comment_status,ping_status,
post_password,post_name,
to_ping,pinged,post_modified,
post_modified_gmt,post_content_filtered,
post_parent,guid,menu_order,
post_type,post_mime_type,
comment_count     
      )
SELECT
post_author,
post_date,post_date_gmt,
post_content,post_title,
post_excerpt,post_status,
comment_status,ping_status,
post_password,post_name,
to_ping,pinged,post_modified,
post_modified_gmt,post_content_filtered,
post_parent,guid,menu_order,
post_type,post_mime_type,
comment_count
FROM wp_posts

2. finding duplicate content in a table.

SELECT post_title,post_content, COUNT(*) AS COUNT
FROM wp_posts_main
GROUP BY post_content,post_title
HAVING COUNT(*) > 1

3.Update all columns with row id for all rows.


UPDATE wp_posts_final t, (SELECT DISTINCT ID
                        FROM wp_posts_final) t1
   SET t.guid = CONCAT("http://www.1947.com/?p=", t1.ID)
 WHERE t.ID = t1.ID