php - How to list most recently updated parent upper in the query? -


enter image description here

i have pic related parent/child tables. every 1 row in parent table, there can 100 or 200 child rows in child table. when upgrade child table; give it's parent row's tid number child's row under thread id column. so, there isn't more 1 parent row each child row.

if had column in parent table "lastchildtimestamp" upgrade related row last child timestamp? if can show me example?

what want achieve keep updated parents upper when list out parents , want make easy. if have better solution or method i'm open too.

there 2 different approaches use solve problem.

  1. create parent.lastchildtimestamp field, use database trigger update it.

see: http://www.techonthenet.com/mysql/triggers/after_update.php

in particular, set after insert , after update triggers in child table update associated parent row.

  1. alternately, instead aggregate data child rows when need read it. query looks like:

select max(timestamp) child child.threadid = (thread id)


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -