java - Creating a custom result set in MySQL -
i'm building app calculates monthly bill amount clients.
i getting data mysql in 3 different queries populate 1 table.
i wanted know if there way join these queries, , create result set default table of choice.
for example, use these quires separately, , data goes same table.
// me prices per hour client. select * roommanager.companyfinance projectname = 'xxx'; output like: shifttype | price ----------|------ ol | 555 off | 548 bkg | 666 snd | 422 //this me amount of products per product client month. select shifttype, count(*) roommanager.dailyrooms project = 'xxx' , company = 'yyy' , daydate \"%yyyy-dd%" group shifttype;"; output like: shifttype | count ----------|------ ol | 2 off | 1 bkg | 0 snd | 3 //this me amount of cancellations select wascancelled, count(*) roommanager.dailyrooms wascancelled = 2 , project = 'xxx' group wascancelled; output like: wascancelled | count -------------|------ 2 | 6
is there way combine queries , single result set, this:
shifttype | price | count | cancelled ----------|---------------|-------------- ol | 555 | 2 | 6 off | 548 | 1 | bkg | 666 | 0 | snd | 422 | 3 |
my bad, union
concats resultsets. wanted customize result set (something that):
select orders.orderid, customers.customername, orders.orderdate orders inner join customers on orders.customerid=customers.customerid;
join
combines 2 tables common field, such projectname , project field, allowing sql engine combine 2 different results 1 result identified common field.
see: http://www.w3schools.com/sql/sql_join.asp
note: i'm writing 'something that' because example, not solution. it's aimed show possibility combine fields of 2 or more tables - it's still work , running specific case.
old (incorrect case) answer:
a possible way might use mysql's union
keyword:
select * myschema.mytable union select * myschema.myothertable
Comments
Post a Comment