WordPress Code: What does pm WP mean in SQL statements?

Source: Internet
Author: User
See the following code:
WordPress used for a long time, some post deleted, but its corresponding post meta data still exist, then how to delete these isolated post meta data? Run the following SQL statement directly in the database management software:
DELETE pm
From Wp_postmeta PM
Left JOIN wp_posts wp on wp.id = pm.post_id
WHERE Wp.id is NULL

----puzzled is, "PM", "WP" what mean?


Reply to discussion (solution)

In the case of SQL instructions, PM is the alias of table Wp_postmeta, WP is the table name of table wp_posts

A little refresher on database knowledge can be recalled.

The label's record is stored in the Wp_terms data sheet. Sometimes, some tags may be created but not used, and they will still be in the datasheet. The following statements can be queried for these unused tags, and you can safely delete them.

SELECT * from wp_terms wt INNER joins wp_term_taxonomy WTT on wt.term_id=wtt.term_id WHERE wtt.taxonomy= ' Post_tag ' and WTT. Count=0
----Thank you for reminding me. I have reviewed it more than once, but I have not been able to tell this usage anywhere. Just saw a similar usage, such as the WT WTT. Ask Tall man, what is the usage of the red font part?

I see. The Red font section WT WTT is the alias of Wp_terms, Wp_term_taxonomy. What I don't understand is that in the following code:
DELETE pm
From Wp_postmeta PM
Left JOIN wp_posts wp on wp.id = pm.post_id
WHERE Wp.id is NULL
Did----Delete pm remove the entire Wp_postmeta table? And that's not what we meant! We just want to delete the isolated Post Meta data.
Also please expert guidance

He doesn't have where wp.id is NULL?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.