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.

Re: QUERY: MAX FUnction Help 80 80
Select resortname from table2 where resortid = (select MAX(resortid) from table1)

Try this.

Re: QUERY: MAX FUnction Help 80 80
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.

Re: QUERY: MAX FUnction Help 80 80

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".

Re: QUERY: MAX FUnction Help 80 80

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.