21320
A  
`SELECT CURDATE();`

+------------+  
| CURDATE() |  
+------------+  
| 2016-01-26 |  
+------------+

B

`SELECT created FROM products;`

+---------------------+  
| created |  
+---------------------+  
| 2015-08-11 11:12:53 |  
+---------------------+

上記のAとBの月の差分をとって、5と出したいのですが、

`SELECT`内で１つにまとめて算出させたのですが、どのような記述になりますか？
CC BY-SA 3.0
2016-01-26T05:21:27.980
21318
2016-01-26T05:50:09.943
2016-01-26T05:44:25.713
10980
10980
question
mysql sql
MySQLの日付とテーブルにはいっているcreatedの日付の差分をとりたい
MySQL の [TIMESTAMPDIFF()](http://dev.mysql.com/doc/refman/5.6/en/date-and-
time-functions.html#function_timestampdiff) を利用します。

```

    SELECT TIMESTAMPDIFF(MONTH, created, CURDATE()) AS diff, created
    FROM products;
    
```
CC BY-SA 3.0
2016-01-26T05:48:49.827
21320
2016-01-26T05:48:49.827
76
21318
answer