473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

MySQL Union statement

Hi Everybody! I want to know how to write union query in mysql.If anybody know the answer of the question please help me.I try the union query but it shows error .So I want to help.
May 18 '07 #1
4 9792
pradeep kaltari
102 Expert 100+
Hi Everybody! I want to know how to write union query in mysql.If anybody know the answer of the question please help me.I try the union query but it shows error .So I want to help.
Hi cvalarmathi,
You can use the UNION operator as:
Expand|Select|Wrap|Line Numbers
  1. SELECT col1,col2,... FROM table1
  2. UNION
  3. SELECT col1,col2,... FROM table2
  4.  
Make sure that the number of columns is same in both SELECT statements.
I hope this helps you.

Regards,
Pradeep.
May 18 '07 #2
Hi cvalarmathi,
You can use the UNION operator as:
Expand|Select|Wrap|Line Numbers
  1. SELECT col1,col2,... FROM table1
  2. UNION
  3. SELECT col1,col2,... FROM table2
  4.  
Make sure that the number of columns is same in both SELECT statements.
I hope this helps you.

Regards,
Pradeep.


Thanks for your reply.It is very usefule to me.I got the answer.Once again I thank you.
May 18 '07 #3
pbmods
5,821 Expert 4TB
For more information:

http://dev.mysql.com/doc/refman/5.0/en/union.html
May 18 '07 #4
Atli
5,058 Expert 4TB
I have edited this threads title to better describe its topic.
Please read the Posting Guidlines before posting.

MODERATOR
May 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ++Captain Tripps++ | last post by:
I am trying to run a fuultext search on two identical tables and use UNION to join the results but no matter what I try, I get a syntax error on the UNION clause. Here's the query: (SELECT...
0
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
0
by: Neculai Macarie | last post by:
Hi! Using Union and Order By gives strange behaviour in the following test-case: drop table if exists gallery; drop table if exists gallery_categ; # create test tables create table gallery...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
3
by: Noozer | last post by:
Trying to get the following SQL to execute in MySQL 4.0... SELECT DISTINCT CategoryID, tblCategory.Category FROM tblCategory AS A INNER JOIN (SELECT Cat FROM ( SELECT tblCategory.Category AS Cat...
10
by: smorrey | last post by:
Hello all, this might better be suited for the MySQL newsgroup, but I figured I'ld post here and see if anyone can help me. I'm trying to create a simple transaction handling system where users...
9
by: noor.rahman | last post by:
I was wondering how it may be possible to query 2 MySQL databases using one query statement from PHP. For instance: SELECT database1.tableA.field1 UNION database2.tableB.field2. My concern...
7
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both...
5
by: inexion | last post by:
Hello, I'll try to explain what I'm trying to accomplish here, hopefully not too bad a task. Basically I have an existing table with data that will be operated on to form new records etc... ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.