bobe_aa
asked on
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!
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!
ASKER
Edited text of question.
ASKER
Edited text of question.
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,FieldsFro mTable2 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.
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,FieldsFro
This would select the specified fields from tables 1 and 2 where the id is the same.
Arjan.
yes, i agree with aarie
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.
Arjan.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i was wrong -
not "select Price from ..."
but "Select Price, Id from ...."
of course
but i think you understand it yourself!
not "select Price from ..."
but "Select Price, Id from ...."
of course
but i think you understand it yourself!
Bob, I suggest you REJECT ilia's answer, as it is almost a complete rip off of my comment.
Arjan.
Arjan.
ASKER
aarie,ilia239
Thanks for you help!
And thanks everyone.
Thanks for you help!
And thanks everyone.
ASKER