I am new to mysql. I would like to create a new table that is a copy of the original one table with another column under a specific condition. What condition is the new column is the new table. I mean:
Let table be the sequence of a given point (x, y). I want to create a temp table (x, y, r), where r = x ^ 2 + y ^ 2 <1 But I did it
CREATE temp LIKE table;
ALTER TABLE temp ADD r FLOAT;
INSERT INTO temp (x,y) SELECT * FROM table WHERE x*x+y*y<1;
UPDATE temp SET r=x*x+y*y;
This is normal, it gives what I want, but my database is much larger than this simple example, and here I calculate twice the radius r in two tables. This is not good for optimization.
Is there a way to pass the sentence to a new column directly?
Thanks in advance.
source
share