开发者

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

开发者 https://www.devze.com 2022-12-15 11:29 出处:网络
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:

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

精彩评论

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