Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate if exist, insert row if not exist in MySQL
    primarykey
    data
    text
    <p>I have asked similar question to this here...</p> <p><a href="https://stackoverflow.com/questions/18377332/three-tables-with-inner-join/18377897?noredirect=1#18377897">three tables with Inner Join</a></p> <p>But I couldn't get enough answer to solve my problem, so I am forced to re-ask again...</p> <p>I have the following table...</p> <p>**</p> <blockquote> <p>anyone who want to play on the data please test it here <a href="http://sqlfiddle.com/#!9/a0807" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/a0807</a></p> </blockquote> <p>**</p> <pre><code>Table1 IDA colB colC 111 a w 222 b w 333 c s 444 b g Table2 IDB colB colC 11 w f 12 w r 13 s g Table3 IDA IDB 111 11 222 12 333 13 444 14 </code></pre> <p>the following code will copy or insert from table1 to table to with out problem, but with wrong table2 IDB (because table2 IDB value should come from inner join to table3)</p> <pre><code>INSERT INTO table2 SELECT * FROM table1 WHERE IDA = 111 </code></pre> <p>But copy all from table1 to table2, which is wrong...</p> <p>so, what I did is...the following inner join...But not working..</p> <pre><code>INSERT INTO table2 (SELECT * FROM table1 b LEFT JOIN table3 c ON c.IDA = b.IDA LEFT JOIN table2 a ON a.IDB = c.IDB) WHERE IDB = 111 </code></pre> <p>That is not working either....</p> <p>But, what I need is exactly...I want to copy from table1 to table to connected over table3, if the row available update if not insert....</p> <p>sorry for asking twice, but I am kin to get some idea from you guys...</p> <p>Please help...thanks in advance... </p> <p>May be using php, to handle if possible...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload