开发者

Help with Select Query in ado.net

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 hel开发者_StackOverflowp or suggestion will be appreciated


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'


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'


SELECT * FROM newsImages WHERE newsImage <> "something" AND newsID = <value>;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜