SELECT id_instansi, nama_file, valid_date,
TIMESTAMPDIFF(DAY, valid_date, CURDATE()) AS selisih
FROM tbl_attachment
我的问题是我只想显示“ selisih ”值= -4的行,而不是全部。 任何人都可以告诉我如何编写正确的查询来解决我的问题吗?
答案 0 :(得分:2)
SELECT id_instansi, nama_file, valid_date,
TIMESTAMPDIFF(DAY, valid_date, CURDATE()) AS selisih
FROM tbl_attachment
WHERE
selisih = -4
答案 1 :(得分:-1)
SELECT id_instansi, nama_file, valid_date, TIMESTAMPDIFF(DAY, valid_date, CURDATE()) AS selisih FROM tbl_attachment
**WHERE** TIMESTAMPDIFF(DAY, valid_date, CURDATE())=-4