Solved

insert with inner join ?

Posted on 2011-09-22
2
515 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
2 Comments
 
LVL 45

Accepted Solution

by:
Kdo 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 109

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to dynamically set the form action using jQuery.
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.

803 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