Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statements

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have two tables in a database. One has the following fields: city and country. The other has : country and currency. The object of this program is that when the user presses a button an input box asks for the city and when you type it in, the city and country are displayed in their text fields. The second part of the project is when you push the show currency button, the currency used in the displayed country should be displayed in the currency textbox. I have to do this using SQL. I've got the first part of searching for a city, but I can't figure out how to make the currency of that city and country display since it's in another table. Could someone please tell me how I can do this using SQL? Thanks
 
Hi,

You can do this in several different ways, here's 2 and a suggestion:

1. SELECT currency FROM TblCon&Cur WHERE country IN (SELECT country FROM TblCit&Con WHERE city='Copenhagen')

2. SELECT currency FROM TblCon&Cur INNER JOIN TblCit&Con ON TblCon&Cur.country=TblCit&Con WHERE city='Copenhagen')

3. Put everything into one table (If this is a good solution depends on how many cities you've got in each country).

Good Luck
Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top