Solved

insert with inner join ?

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now