Try this code
INSERT INTO data_waktu_vaksinasi
(id_binatang, id_vaksin, tanggal_vaksin, status_vaksin)
VALUES
(
1,
1,
(
SELECT date FROM
(SELECT DATE_ADD(max(tanggal_vaksin), INTERVAL 1 YEAR) date
FROM data_waktu_vaksinasi, 'belum') subquery
)
)
I didn't test this code, but I tested an equivalent code (also an INSERT INTO
statement with same table in subquery as in master-query)
The trick
is the wrap the subquery with the same table into another subquery, that only queries the columns from the SELECT
-clause of the actual subquery.
Result: Mysql doesn't complain
I don't know why this works
It seems to me kina like cheating