Solved

insert with inner join ?

Posted on 2011-09-22
2
522 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

756 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