开发者

How do I exclude a specific row from a result set?

I want to let the user select a value from a combo box, and then exclude a row from the result set of a stored procedure based on that selection. Something like this:

Sele开发者_Go百科ct RegNo from Vehicle Except select  VehicleID from Trip


I hope this is what you try to achieve:

SELECT RegNo
FROM Vehicle
WHERE _id NOT IN ( 1, 2 )

_id is the primary key of your table Vehicle, put those IDs into the brackets that you want to exclude.

I use the NOT IN to allow excluding more than one row if necessary.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜