我有一个查询 -
DELETE FROM invoice
WHERE inv_date < 2018-03-31 - INTERVAL(72) MONTH TO MONTH)
当我执行时,我收到错误说明 -
1260:无法在指定类型之间进行转换。
&#34; 2018-03-31&#34;?我该怎么写才能执行并获得结果?
答案 0 :(得分:0)
答案 1 :(得分:0)
如a_horse_with_no_name中的comment所述,您需要使用DATETIME文字,而不是一系列整数减法:
# generate alphabet as arr:
arr=( {1..26} )
i=$(($RANDOM%24+1))
# left and right
l=$(echo ${arr[$i]})
r=$(echo ${arr[$i+1]})
# reusing arr for testing:
echo ${arr[@]} | tr "a-z" "$r-za-$l"
echo "secret:" | tr "a-z" "$r-za-$l" ; echo $l $r $i
amkzmb:
h i 7
或者:
DELETE FROM invoice
WHERE inv_date < DATETIME(2018-03-31) YEAR TO DAY - INTERVAL(72) MONTH TO MONTH
在标准SQL中,您可以编写:
DELETE FROM invoice
WHERE inv_date < DATETIME(2018-03-31) YEAR TO DAY - 72 UNITS MONTH