473,835 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

merge query in mysql

29 New Member
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 5159
ronverdonk
4,258 Recognized Expert Specialist
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
barrathi
29 New Member
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
barrathi
29 New Member
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 Recognized Expert Specialist
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 Recognized Expert Specialist
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
barrathi
29 New Member
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
1788
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 for the following reason: mysql> create table test_table (country CHAR(2) NOT NULL) TYPE=MERGE UNION=(countries); Query OK, 0 rows affected (0.00 sec)
0
3150
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 GByte of RAM. I have a database collecting logs. Each day, a new table is created. In order to allow for queries across more than one day, I use 'MERGE'
2
3253
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 generated (or before), assign the current date to the field in the main table the query data source is based on. Is this even possible? If so, how could I do it? Here is the code that works so far:
1
3140
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 letters. I have a department selection pop-up form where the departments are listed in a listbox. The value of the listbox is DepartmentID. On the form is a Create Mail Merge button which is coded to open the mail merge and make the pop-up form not...
8
9531
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 each person for whom a mail merge letter is desired. The query reads address info from the table for each record where is true.
3
5593
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 document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
0
2774
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 underlying table (in a memo field) in html format, as one big block of text. The memo field is called (I named it before I realized that I needed to separate title from text).
3
11358
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 supports a single table. Are there any utilities or simple scripts avaialble that would accomplish this?
1
2056
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 get desired data Query2->SELECT Sheet1.state, code,Sheet1.address,stdcnt FROM Table5 INNER JOIN Sheet1 ON Table5.code = Sheet1.centrecode order by state,stdcnt desc; kindly help me to merge these two queries into one
0
9802
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10517
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10230
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9343
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7765
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6961
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5632
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3086
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.