quano
quano

Reputation: 19102

MySQL - reference column in function call

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?

Upvotes: 0

Views: 426

Answers (1)

eumiro
eumiro

Reputation: 212835

Don't use quotes:

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

Upvotes: 2

Related Questions