Forum Moderators: open
I would like to return the selected results order by last modified timestamp. Without duplicate article numbers.
I have two tables one with each
+---------+--------+
¦ article ¦ author ¦
+---------+--------+
¦ 0001 ¦ Sam ¦
¦ 0002 ¦ Tom ¦
¦ 0003 ¦ Cindy ¦
¦ 0004 ¦ Val ¦
+---------+--------+
Article History
+---------+--------+---------------------+
¦ article ¦ editor ¦ timestamp ¦
+---------+--------+---------------------+
¦ 0001 ¦ Sam ¦ 2009-01-20 21:25:08 ¦
¦ 0002 ¦ Tom ¦ 2009-03-21 17:54:21 ¦
¦ 0001 ¦ Val ¦ 2009-04-05 12:10:10 ¦
¦ 0002 ¦ Val ¦ 2009-04-08 19:05:59 ¦
+---------+--------+---------------------+
Edit:this is incorrect, have to run but will return to this later, sorry --> To avoid duplicates, use distinct.
select distinct (articles.article), articles.author, ar_history.editor,ar_history.timestamp
from articles,ar_history where
articles.article=ar_history.article
order by ar_history.timestamp desc;
asc = earliest first, desc = most recent first. You can substitute
from articles,ar_history where articles.article=ar_history.article
with
from articles left join ar_history on articles.article=ar_history.article
Should be synonymous if article always has a value.