我在sql查询中有正确的错误消息(存在时的消息)的问题,该错误消息应该在不存在时插入记录...
例如:
INSERT INTO list (code, name, address,)
SELECT 'ABC', 'ABC name', 'Johannesburg'
FROM list
WHERE NOT EXISTS(
SELECT code, name, address
FROM list
WHERE code = 'ABC'
AND name = 'ABC name'
AND address = 'Johannesburg'
)
LIMIT 1
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
是否可以制作额外的错误消息,告知该记录是否已经存在?
感谢您的任何建议