473,395 Members | 1,815 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,395 software developers and data experts.

merge query in mysql

hai all,

how to merge the two table( i need query)

ex:
table a

eno ename
1 a
2 b


table b

eno ename

3 c
4 d


i need result like
table b

1 a
2 b
3 c
4 d

i need uppend the data(update)


help me.

thanks & regards
munibarrathi.p
Feb 5 '07 #1
6 5141
ronverdonk
4,258 Expert 4TB
Since you don't give any information on keys or what to do with duplicates, the basic statement for this is the INSERT statement
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_b SELECT eno, ename FROM table_a;
Ronald :cool:
Feb 5 '07 #2
Since you don't give any information on keys or what to do with duplicates, the basic statement for this is the INSERT statement
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_b SELECT eno, ename FROM table_a;
Ronald :cool:

Hi ronald,

iam asking
oracle merge query:( i need like this type of query in mysql)
---------------------------

merge into tablename2 a
using tablename1 b
on (a.eno=b.eno)
when matched
then update
set a.ename=b.ename
where a.eno=b.eno
when not matched
then insert (eno,ename)
values (80,'ram');


if any possible tell me

thakns in advance

barrathi
Feb 6 '07 #3
Since you don't give any information on keys or what to do with duplicates, the basic statement for this is the INSERT statement
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_b SELECT eno, ename FROM table_a;
Ronald :cool:

hi ronald,

iam asking merge query i want to update the table(uppend)

if i have a two table

table1:
---------

1 a

2 b

table 2
---------
3 c

4 d


i want to uppend the table

result like

1 a
2 b
3 c
4 d

in oracle merge query

merge into tablename2 a
using tablename1 b
on (a.eno=b.eno)
when matched
then update
set a.ename=b.ename
where a.eno=b.eno
when not matched
then insert (eno,ename)
values (80,'ram');


like this in mysql i need

if possible tell me

thanks
barrathi
Feb 6 '07 #4
ronverdonk
4,258 Expert 4TB
MySQL does not have a MERGE query, so you'll have to split it into 2 queries.

Ronald :cool:
Feb 6 '07 #5
Motoma
3,237 Expert 2GB
You could do a similar thing with a UNION, but it would not modify either table.

Here is a simple example:
Expand|Select|Wrap|Line Numbers
  1. SELECT 1 AS Col1, 'A' AS Col2
  2. UNION
  3. SELECT 2 AS Col1, 'B' AS Col2
  4.  
Feb 6 '07 #6
hi

thanks for your information

regards
barrathi
Feb 7 '07 #7

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

Similar topics

0
by: Pierre-Luc Soucy | last post by:
Hi, I was working on some merge tables this morning and it worked fine, but after a few unsuccessful table creation requests (I was making some tests), I could not alter or select from a table...
0
by: Johannes B. Ullrich | last post by:
--=-WKgoK98ejo9BZyGYc3N/ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I am having problems with MySQL 4.0.12 on RedHat Advanced Server 2.1 using a dual Xeon with 8...
2
by: William Wisnieski | last post by:
Hi Everyone, Access 2000 I have some code behind a button that performs a word merge with a query data source. The merge works fine. But what I'd like to do somehow is after the merge is...
1
by: Lisa | last post by:
I have a query named QryDept where one of the fields is DeptID. The query is used for the data source of a mail merge letter. I would like to control which department is to get the mail merge...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Phil C. | last post by:
Hi, I'm using Access 2000. I have a Select Query that uses the MID function to separate the actual text of articles from the title of the articles. The articles are enterd into the...
3
by: cdelarte | last post by:
I would like to be able to mail merge records from multiple mysql tables using a simple template, preferably via a command line script. MSWord mail merge via ODBC will not work for me as it only...
1
by: kkshansid | last post by:
State wise count of excellent (max pass count centres) query1-> Select code,sum( IF(PASS_FAIL='P',1,0)) AS Cp from table group by code I made table5 from above query then i executed query2 to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.