Forum Moderators: coopster
If I have 2 query (simplified)
select * from tableA where "a lot of conditions";
select * from tableB where "a lot of conditions";
both query will create a different result table. Is it possible in some way to JOIN this 2 table and make them in one query? I mean how to I make the first quest as "Table 1" and query 2 as "Table 2" so I can do something like
select * from "Table 1", "Table 2" where "more conditions".
I will try to make an example
Lets say we have table1:
id
country
population
flag
and table2
id
city
country_id
We want to select a flag to put account a city name:
SELECT flag FROM table1,table2 WHERE table1.id=table2.country_id
Hope this helped :)
For example,
select fieldA, fieldB, count(*) from tableA where something1 and something2 groupB, fieldA, fieldB order by fieldA desc
So this complicated query return a table. How do I, in any way, use the result of the QUERY to feed as a table to another query?
I think I am looking for subselect. But most web host still doesn't run MySQL 4.1 :(
I used to do everything with PHP, but later I found out MySQL is so powerful in doing all those sorting and calculations itself! So I am trying to master them now.
What I love most is the aggregate functions of group by!
count(DISTINC field)
sum()
max()
They are just too powerful and save a lot of time processing with PHP. Why remake the wheel? haha.
I also read that is a new ROLLUP in MySQL 4.11 where it will add the TOTAL to the end of the result. COOL!