MySQL Forums
Forum List  »  Newbie

help creating sql query
Posted by: Francesco
Date: August 10, 2005 06:22AM

Hi all,
I'm new to sql in general and I need to create what is for me a complex sql query.
I try to explain the problem as easly as possible.
My db has 3 tables called 'shops', 'item' and 'prices'.

Table shop is made by:
id (int)
name (varchar)
address (varchar)

Table item is made by:
id (int)
cod (varchar)
name (varchar)
desc (varchar)
reg_date (date)
user (varchar)

Finally, table price want to record prices for items in different shops in different times:
recordid (int)
iditem (int) -> this refers to item.id
idshop (int) -> this refers to shop.id
date (date)
price (float)
user (varchar)

Now I would like to create a web page with a table with shops in colums and a row for every product with the last (referred to price.date) price recorded for the every shop (or a null value if there is no rcord for a specific item/shop combination).

I coudl do that by doing a single query for every item and every shop (this means items * shops queries), but I bet there is a better way....

Can anyone help me, pls?

Regards,

Francesco

Options: ReplyQuote


Subject
Written By
Posted
help creating sql query
August 10, 2005 06:22AM
August 10, 2005 07:48AM
August 10, 2005 09:17AM
August 10, 2005 09:31AM
August 10, 2005 09:32AM
August 10, 2005 10:04AM


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.