SQL tutorial-Union

Union



With SQL you can combine multiple queries that have the same number of fields.
Example: We want to combine records from TblProduct table and TblProduct1 table.

TblProduct table:

ProID ProName UnitPrice Qty CatID
P001Angkor 20$ 10 Cat003
P002ABC 50$ 8 Cat003
P003Khmer Noodle 20$ 10 Cat004

TblProduct1 table:
ProID ProName UnitPrice Qty CatID
P004Anchor 18$ 13 Cat003
P005Cocacola 25$ 15 Cat003

SELECT * FROM TblProduct
UNION
SELECT * FROM TblProduct1;

Result:
ProID ProName UnitPrice Qty CatID
P001Angkor 20$ 10 Cat003
P002ABC 50$ 8 Cat003
P003Khmer Noodle 20$ 10 Cat004
P004Anchor 20$ 13 Cat003
P005Cocacola 25$ 15 Cat003




Comments

Name:
Comment:
Enter the text:
CAPTCHA image

.........................................................................................................................Home | Forum | About | Contact
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word.
However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.
Copyright @ 2011-2013 worldbestlearningcenter. All Rights Reserved.
Home Programming Web DB & App Questions Exercises Tips Programs FAQs Download About
Computer-Wbest
Popular Pages
You might like