Title: SQL Query Help
Last modified: August 18, 2016

---

# SQL Query Help

 *  [trmtnbike](https://wordpress.org/support/users/trmtnbike/)
 * (@trmtnbike)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/)
 * Is anyone aware of a way to query for the date and time a category last had a
   post added to it?
 * Please note: I cannot rely on the timestamp of the most recent post in the category,
   as they do not necessarily reflect the date in which a post was added to a category.
   For instance, if a post was made on August 1, 2005, and was then added to a category
   on July 20, 2006, I would want a way to display that the category was last updated
   on July 20, 2006.

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

 *  [jwurster](https://wordpress.org/support/users/jwurster/)
 * (@jwurster)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422574)
 * There is this fuzzy recent updates plugin at [http://www.semiologic.com/software/recent-updates/](http://www.semiologic.com/software/recent-updates/).
 *  Thread Starter [trmtnbike](https://wordpress.org/support/users/trmtnbike/)
 * (@trmtnbike)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422830)
 * I don’t think the fuzzy recent updates plugin is what I’m looking for, but thanks.
 *  [geoffe](https://wordpress.org/support/users/geoffe/)
 * (@geoffe)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422834)
 * WP doesn’t record a timestamp for when a post is added to a category, so you’d
   have to modify the DB [the post2cat table] and the core files to do so. Or perhaps
   the postmeta table, although that would get much messier.
 *  Thread Starter [trmtnbike](https://wordpress.org/support/users/trmtnbike/)
 * (@trmtnbike)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422837)
 * Hi Geoffe,
 * Thanks for getting back to me. I added a timestamp to the post2cat table a long
   while ago to give myself this functionality, but was hoping that someone with
   more knowledge of the WordPress DB schema than I would know of a way around doing
   so.
 * The ultimate aim was to make my photoblog theme more easily distributable.
 *  [geoffe](https://wordpress.org/support/users/geoffe/)
 * (@geoffe)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422840)
 * the timestamp on post2cat is your best method, you just need custom SQL queries
   to pull that information. I suppose that is just what you chose to do.
 * I suppose your theme can be made to modify a table to add the timestamp column
   as part of an install function. As i said, the postmeta table could store the
   info, but it’s less ideal.

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

The topic ‘SQL Query Help’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [timestamp](https://wordpress.org/support/topic-tag/timestamp/)

 * 5 replies
 * 3 participants
 * Last reply from: [geoffe](https://wordpress.org/support/users/geoffe/)
 * Last activity: [19 years, 11 months ago](https://wordpress.org/support/topic/sql-query-help/#post-422840)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
