Wednesday 21 April 2010

Describe UNION in mysql?

Union is used to merge records coming from different or same tables on different conditions.

for example:

SELECT id, name, age FROM employee WHERE id = 2
UNION
SELECT id, name, age FROM employee WHERE id = 5

Note:  both query contains same number of fields.


In above example, there are 3 fields in first query and 3 fields in second query.

Cheers!

1 comment:


  1. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Offshore PHP Development in India

    ReplyDelete