Forum Moderators: coopster

Message Too Old, No Replies

Displaying results from Two Tables

         

BlackRaven

4:47 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Hi, wondering if someone could help me ....yet again.

Ook, i am still in the early stages of my new Project and run into a bit of problem. How does one go about displaying results from 2 tables as one. The 2 tables have identical sturcture except the price value, one is in CDN and the other is in US $. I would like the results from the two tables be displayed as one and ordered according to the price, i do realize i might have to convert the CDN into US and Vice Versa,...Oh..just remebered does anyone know where i could dynamically get the currency rates? thanks

jusdrum

5:32 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



You can do a table join, like so:

select u.ItemName, u.ItemPrice as USPrice, c.ItemPrice as CanadianPrice from USItems u left join CanadianItems c on u.ItemID = c.ItemID;

Which should yield results:

ItemName: Red Cog
USPrice: 5.00
CanadianPrice: 9.95

This will only pick items that have the same ItemID. If you want to base it on the Name, change the join condition to:

u.ItemName = c.ItemName

However, joining on IDs is ideal. If the two tables are identical as you say, the IDs should be the same.

Hope this helps!