If I have three different tables like this
table_1
Field 1: victories
Field 2: name
table_2
Field 1: name
Field 2: birthday
Now I would want to get the birthday of the person with the most victories.
So I would do something like this (pseudo code):
select victories from table_1 and sum_it_all
get name and pass name to table_2
select birthday from table_2 where name
Ok, this is pretty ugly pseudo code, but I hope you get the point.
Using Andomar's solution works fine. Now I tried to nest another table in it, like this though:
select address
from table_3
where birthday =
(
select birthday
from table_2
where name =
(
select name
from table_1
group by
name
order by
sum(victories) desc
limit 1
)
)
I do get a correct answer, but for some reason also get a null back. And how would I output the sum of victories?