You can also display records from two tables having same structure i.e. having same datatypes by using a UNION operator ..

UNION OF TWO SELECT STATEMENTS

SELECT field1, field2, field3,.... FROM Table1 UNION SELECT field1, field2, field3,.... FROM Table2

For isssuing the above command we have to see that both the tables have the same table structure.

Example : if two table table1 and table 2 are having following data then : Data of table 1

fields - Name Address1 Address2 TelNo
Record 1 data "A.Symonds" "Gr.Floor, ABC Apartments" "XYZ Road, Area XMS" "5879879870"
Record 2 data "M. Jones" "3rd Floor, HTX Apartments" "GHJ Road, Area ZXC" "6548736843"
Record 3 data "G. Haynes" "2nd Floor, JUI Apartments" "RTY Road, Area OPU" "4564654879"


Data of table 2

fields - Name Address1 Address2 TelNo
Record 1 data "A.Symonds" "3rd Floor, UTV Apartments" "BHY Road, Area ADF" "4564897987"
Record 2 data "M. Jones" "Gr. Floor, AJH Apartments" "ATY Road, Area HTY" "4894465465"
Record 3 data "M. Koni" "4th Floor, RED Apartments" "MXS Road, Area NOT" "7897246814"


And if the command is given as below :

SELECT Name, Address1, Address2, Telno FROM Table1 UNION SELECT Name, Address1, Address2, Telno FROM Table2

The above command will give the output as follows :

Results-Fields Name Address1 Address2 TelNo
Record 1 data from table1 "A.Symonds" "Gr.Floor, ABC Apartments" "XYZ Road, Area XMS" "5879879870"
Record 2 data from table1 "M. Jones" "3rd Floor, HTX Apartments" "GHJ Road, Area ZXC" "6548736843"
Record 3 data from table1 "G. Haynes" "2nd Floor, JUI Apartments" "RTY Road, Area OPU" "4564654879"
Record 4 data from table2 "A.Symonds" "3rd Floor, UTV Apartments" "BHY Road, Area ADF" "4564897987"
Record 2 data from table2 "M. Jones" "Gr. Floor, AJH Apartments" "ATY Road, Area HTY" "4894465465"
Record 3 data from table2 "M. Koni" "4th Floor, RED Apartments" "MXS Road, Area NOT" "7897246814"


From the above you will see that all the records are listed one below other in the result.

Incomedia WebSite X5 Evolution