Insert / Select with different values Possible in MYSQL?
4 answers
It really depends on what that value is ...
If you want to insert some known constant you can use:
INSERT INTO tblname(f1,f2,f3)
SELECT f1,"foo",f3 FROM othertbl
If you want to insert a value in f2
, but twice, you can use:
INSERT INTO tblname(f1,f2,f3)
SELECT f1,f2*2,f3 FROM othertbl
If you want to insert the amount f1
and f3
, you can use:
INSERT INTO tblname(f1,f2,f3)
SELECT f1,f1+f3,f3 FROM othertbl
But I know these are probably the wrong functions for math, so I will need to find the right way to get my examples to work, but the idea should be clear.
+2
source to share
U can use string or math functions mysql a / c ur needs
you can find them here
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html
http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html
0
source to share