Skip navigation links

MySQL Forums :: Newbie :: Syntax problem


Advanced Search

Syntax problem
Posted by: MÃ¥rten Hansson ()
Date: January 20, 2013 05:32AM

Hi,
I can't figure out the correct syntax. I have 2 tables like this:

table articles
id
name

table prices
id
articles_id (foreign key)
price
date

One can register several prices for one article. This way the price history for an article is kept.

I like to write a question that returns all articles, each with its newest price.

My try doesn't work:

SELECT article, price, date FROM articles, prices
WHERE articles.id = prices.articles_id
AND date = (SELECT MAX(date) FROM prices WHERE articles.id=prices.articles_id)

Options: ReplyQuote


Subject Written By Posted
Syntax problem MÃ¥rten Hansson 01/20/2013 05:32AM
Re: Syntax problem Peter Brawley 01/20/2013 11:53AM
Re: Syntax problem MÃ¥rten Hansson 01/20/2013 04:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.