0

Hello everyone,

I need help. I have two table name:

Table 1:

resortid resortlocation

Table 2

resortid resortname

Now I want to get the maximum of resortlocation then getting the name of that specific resort also. I am having a hard time. Can someone please help me?

Thanks.

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by slider_44
0
Select resortname from table2 where resortid = (select MAX(resortid) from table1)

Try this.

Hello sir,

Thank you for the reply. But what im looking is the max of resortloc.

Table 1:

resortid resortloc
001 20 miles
002 30 miles

Table 2

resortid resortname
001 Shangri-la
002 Dos Palmas

The result should be:

Dos Palmas 30 miles

The max resortloc whould be the result plus the name of that resort. Thank again.

0

So you will need to join the tables like so:

SELECT resortloc, resortname FROM table1
INNER JOIN table2 ON table1.resortid = table2.resortid
WHERE table1.resortloc = (SELECT MAX(resortloc) FROM table1)

This is of course assuming that resortloc is a numeric value, ie 30 not "30 miles".

0

So you will need to join the tables like so:

SELECT resortloc, resortname FROM table1
INNER JOIN table2 ON table1.resortid = table2.resortid
WHERE table1.resortloc = (SELECT MAX(resortloc) FROM table1)

This is of course assuming that resortloc is a numeric value, ie 30 not "30 miles".

Thank you. Thank you. That did it. :D

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.