MYSQL - INSERT INTO using WHERE condition of Table 1 -


After reading the "INSERT INTO" post and the document, I am still unsure what I want is possible or not . I want to change the update below to an INSERT, because I have many 100-thousand (speed issues):

  update city c SEET c.g17h = '3196504', c g17q = '25 9 3487 ', c.g17k =' 0 ', c.g17w =' 0 ', c.g17s =' 0 'where p17t = 30 and p17l =' 30 '; Update city c SET c.g1h = '0', c.g1q = '0', c.g1k = '0'  , C.g1w = '0', c.g1s = '0', where p1t = 1 and p1l = '1'; However, my best solution does not work:  
  Enter city (g17h, g17q, g17k, g17w, g17s) and select '3196504' , '25 9 3487', '0', '0', '0' semestore tab where p17t = 30 and p17l = '30';   

This is definitely because my situation where I can be satisfied only in the first table (city), but not in the second, which is just a table of values, while the city's Table data sets where each ID contains p17t, p17l and special values ​​for it. For clarification:

  looks like the first table (city) cityid1, ownerid1, islandid1, p17t, p17l cityid2, ownerid2, islandid2, p17t, p17l   

With different values ​​for each line for P17t and p17l

So, my questions will be: 1. Is it possible to write INSERT-query with a WHERE status for the table being included in it? 2. If not, do I have to stay in my updates or is there any other (fast!) Solution?

Thanks for the community!

litotes

It is possible to insert quick replies with a select statement

  MyTable (Val1, Val2) Select some values, from MyOtherTable to Ultravale, where date = Getdate ()   

On the other hand, Can also update the example:

  update T1 set t1.Val1 = t2.SomeValue, t1.Val2 = t2 Another reality from MyTable t1 is included in t1.PK = t2.FK on MyOtherTable T2, where t2.Date = getdate ()   

edit:

when I I read the following questions, I agree that the p17t and p17l are from the Honorable Streets tab.

  update city c SET c.g17h = '3196504', c.g17q = '25 9 3487', c.g17k = '0', c.g17w = '0', c .g17s = '0' where p17t = 30 and p17l = '30';   

==> It has been changed to:

  UPDATE c SET c.g17h = '3196504', c.g17q = '25 9 3487 ', c.g17k =' 0 ', c.g17w = '0', c .g17s = '0' to City C, ValueStretab V. WHERE c.SomeCol = v.SomeCol - Here, your relationship should be present! And v.p17t = 30 and v.p17l = '30';    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -