帮助 ado.net 中的选择查询

发布于 2024-11-08 23:20:31 字数 213 浏览 0 评论 0原文

我有一个表(newsImages),其中包含列 newsID(外键) , newsImage , imageID(主键),我的查询是什么 从 newsImages 中选择 newsImage 其中 newsID = 'something'

查询返回所有具有特定 newsID 的图像,我想要的是从结果查询中删除图像名为“something”的行。任何帮助或建议将不胜感激

I have got a table(newsImages) with columns newsID(Foreign Key) , newsImage , imageID(primary Key), What my query is Select newsImage From newsImages Where newsID = 'something'

The query returns all the images with specific newsID, What I want is to remove a row who has image named"something" from the resultant query. Any help or suggestion will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぽ尐不点ル 2024-11-15 23:20:31

您会这​​样做

DELETE FROM newsImage
WHERE newsID = 'something'

,但要小心,您的 ID 字段看起来好像是文本字段。

你确定ID字段保证是唯一的吗?它是否被定义为主键?如果不是,您可能有多个具有相同 ID 的行,并且您可能会删除比预期更多的行。

编辑

啊,好的

SELECT newsImage From newsImages 
Where newsID = 'something'
AND newsName <> 'somethingElse'

You would do

DELETE FROM newsImage
WHERE newsID = 'something'

But be careful, it looks as though your ID field is a text field.

Are you sure that the ID field is guaranteed to be unique? Is it defined as a Primary Key? If not you may have several rows with the same ID and you may delete more than you were expecting to.

EDIT

Ah, ok

SELECT newsImage From newsImages 
Where newsID = 'something'
AND newsName <> 'somethingElse'
一身软味 2024-11-15 23:20:31

选择除 ID 为“something”的 newsImage 之外的所有内容,

 Select newsImage From newsImages Where newsID <> 'something'

从表 newsImages 中删除 ID 为“something”的 newsImage

 delete from newsImages where newsID = 'something'

To select everything but the newsImage with id 'something'

 Select newsImage From newsImages Where newsID <> 'something'

to delete newsImage with ID 'something' from the table newsImages

 delete from newsImages where newsID = 'something'
够运 2024-11-15 23:20:31
SELECT * FROM newsImages WHERE newsImage <> "something" AND newsID = <value>;
SELECT * FROM newsImages WHERE newsImage <> "something" AND newsID = <value>;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文