A MySQL language question?

I have this command:

  select MAX(Price) from Sales where Time=19991010

When running done.It can be return  19991010 day's Max Price,But how to return The ID field corresponding Max Price in one command£¿

And another I Select from two table,there is two way:

  A:use join
  B:where Table_One.ID=Table_Two.ID

How I choose it?

Thanks for you view!
bobe_aaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bobe_aaAuthor Commented:
Edited text of question.
0
bobe_aaAuthor Commented:
Edited text of question.
0
bobe_aaAuthor Commented:
Edited text of question.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

aarieCommented:
Let's start with the first question...
If I'm not mistaken, you can get the corresponding ID by simply adding id to the query. The query would then look like:

select max(price),id from Sales where Time=19991010

The second question...
B is a way to join the two tables (that's what the part where table1.id = table2.id is for). Therefore, you don't need to choose. Your query would look like:

select FieldsFromTable1,FieldsFromTable2 from table1,table2 where table1.id = table2.id

This would select the specified fields from tables 1 and 2 where the id is the same.

Arjan.
0
freshmeatCommented:
yes, i agree with aarie
0
aarieCommented:
Bob, if my previously posted comment has helped you out, accept it as an answer. If not, let us know so we might be able to help you.

Arjan.
0
ilia239Commented:
first question:

use this query:
select Price from Sales
Order by Price Desc Limit 1;

second question:
already clean?

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ilia239Commented:
i was wrong -
not "select Price from ..."
but "Select Price, Id from ...."
of course

but i think you understand it yourself!
0
aarieCommented:
Bob, I suggest you REJECT ilia's answer, as it is almost a complete rip off of my comment.

Arjan.
0
bobe_aaAuthor Commented:
aarie,ilia239
Thanks for you help!
And thanks everyone.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.