Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 删除表中的所有帖子,大图片有值的帖子除外?_Sql_Sql Delete - Fatal编程技术网

Sql 删除表中的所有帖子,大图片有值的帖子除外?

Sql 删除表中的所有帖子,大图片有值的帖子除外?,sql,sql-delete,Sql,Sql Delete,我想删除表中的所有帖子,除了big_image有值的帖子 我几乎什么都试过了,但都没用! 这是最后一个: sql3="delete from links where userId="& session("user_id") &" and big_image NOT IN (select big_image from links where userId = "& session("user_id") &" and big_image="& bgbil

我想删除表中的所有帖子,除了big_image有值的帖子

我几乎什么都试过了,但都没用! 这是最后一个:

sql3="delete from links where userId="& session("user_id") &" 
and big_image NOT IN (select big_image 
from links 
where userId = "& session("user_id") &" and big_image="& bgbild &");"

我非常感谢您的帮助。

删除userId=“&session(“user\u id”)&”和isnull(big\u image)、=”的链接


请将您的查询参数化,否则您可能很快就会发现通过SQL注入的方式在链接中没有任何记录。

也许我忽略了什么,但是如果您知道
大图像的值,您想查找(
bgbild
)您就不能使用它吗

sql3= "delete from links where userId="& session("user_id") &" 
 and big_image != " & bgbild
嗨,伙计们 我已经测试了所有这些,但我无法让它工作:-)

现在我有:

sql3=“从userId=“&userIdet&”和big_image不为空的链接中删除;”


它没有删除所有其他帖子,而是在我第二次单击按钮时删除了带有图像的帖子?

旁注-将内联SQL更改为参数化存储过程,否则您将面临注入攻击;)谢谢大家的帮助,现在开始工作了,记住11分钟,累了就不要编程;-)Oops-应该说是NULL,去掉了“not”。
sql3= "delete from links where userId="& session("user_id") &" 
 and big_image != " & bgbild