Forum Moderators: coopster

Message Too Old, No Replies

Postgresql getting data from another table

Postgresql getting data from another table

         

Imy_S3

11:25 pm on Feb 9, 2004 (gmt 0)

10+ Year Member



I have two tables,

cinema which has columns ID that is primary, name and price that
references prices in the pricestable.

pricetable with columns ID that is primary key and prices.

pricetable will look like this

ID Price
1 3.50
2 4.50
3 9.60

So when the user is inputting data into the cinema table they can just
type in 1, 2 or 3 instead of typing in different values.

This is so if there is a change in prices they need to be only updatedin
the prices table.

Problem is i dont know to go about doing this in Postgresql.

I look forward to hearing from you soon.

coopster

1:01 am on Feb 10, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you saying you don't know how to JOIN the two tables to get the data back out for display in the browser? You simply need to JOIN the two tables to get your information:

SELECT name, prices FROM cinema, pricetable WHERE cinema.price = pricetable.ID

Imy_S3

10:53 am on Feb 10, 2004 (gmt 0)

10+ Year Member



Hi

But where do i execute this query?

As the information that is going to be entered will be on a web page.

so for examle the user will type 1,2 or 3 accordingly on the webpage.

So on submit the information will be accessed.

Thanks