开发者

MySQL - reference column in function call

开发者 https://www.devze.com 2023-02-07 05:33 出处:网络
I got a number in a table, which I want to use for the DATE_ADD function in MySQL. So something like this:

I got a number in a table, which I want to use for the DATE_ADD function in MySQL.

So something like this:

SELECT DATE_ADD(开发者_高级运维'2011-01-02', '+INTERVAL some_table.column DAY') AS newdate FROM some_table 

This will however not work, as MySQL will not understand some_table.column is a column with a value etc. Any help please?


Don't use quotes:

SELECT DATE_ADD('2011-01-02', INTERVAL some_table.column) AS newdate FROM some_table 
0

精彩评论

暂无评论...
验证码 换一张
取 消