I have two tables with different fields in that and having only one common field as primary key/foreign key. How can i create temporary table with new fields in that, while selecting some of the fields from two existing tables? And i need to insert values once after the temp table creation.
Situation 1: I need to do this when i need to generate some reports from two existing tables in one single click like create table if not exists already, insert values in it, have to produce the result. have to do this all in single click.
situation 2: I have rank field in table 2. According to rank field, new fields can be created in the new temp table. For ex: if rank>1<100, then rank1 field has to be created in temp table. if rank >101<200, then rank2 field has to be created.
Situation 3: If the select query generates number of records then i want to insert that in one row itself without making too many rows
Ex:
If i am producing some results as the following way
Date rank
11-01-2015 11
11-01-2015 120
11-01-2015 210
i need to create temp table in such a manner to combine all the ranks with only one date field in it and with rank1=11, rank2=120 and rank3=210
Then i can be able to get all ranks through the date in single query.