mysql - Insert Select with Multiplication from other table -


i want insert data table1 table2 data in table2 multiplicated value @ table3.

table1 , table2 has same column (id,rangking,status,access,facility,popularity) (id auto increment) table2 has data :

id | rangking | status | access | facility | popularity

1 | 9 | 4 | 2 | 4 | 6

2 | 4 | 5 | 1 | 2 | 7

3 | 5 | 8 | 5 | 3 | 4

table3 has data :

id | value
c2 | 0.2
c3 | 0.5
c4 | 0.1
c5 | 0.3

$sql = mysqli_query ($koneksi, "select value             table3 id ='c2'") or die(mysqli_error($koneksi)); $c2 = mysqli_fetch_array($sql);  $sql = mysqli_query ($koneksi, "select value                 table3 id ='c3'") or die(mysqli_error($koneksi));     $c3 = mysqli_fetch_array($sql);  insert table1 (rangking,status,access,facility,popularity)  select (rangking*$c2['value'] rank,status *$c3['value'] stat,access,facility,popularity) table2 

from query found error, help?

you select column named value should accessing value in $c2 (and don't need alias in select (for insert/select values assigned position)

insert table1 (a2,a3,a4,a5)  select (a2*$c2['value'] a2,a3,a4,a5) table2  

..

$sqltest = mysqli_query ($koneksi, "insert table1 (a2,a3,a4,a5)      select (a2*$c2['value'] a2,a3,a4,a5) table2") or die(mysqli_error($koneksi)); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -