Solved

insert with inner join ?

Posted on 2011-09-22
2
527 Views
Last Modified: 2012-05-12
In Mysql, I want to do an Insert with a where clause indicated by an inner join.

This would be like:

insert into table1 (id,  ts)
INNER JOIN table1  ON (table1.id` = table2.id)
values (1,2)

How can I do this?
0
Comment
Question by:pillmill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 36584696
Hi Pill,

You need to generate a result set that you select from

INSERT INTO mytable (id, ts)
SELECT (id, t2)
FROM table1
INNER JOIN table2
  ON table1.key = table2.key;


Good Luck,
Kent
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 36595237
This strikes me as kind of an odd idea.  And I am wondering, "what is the design or business objective?"  

If you want to INSERT INTO table1 a row with id=1 and ts=2, what has table2 got to do with this?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question