如何根据单元格值删除行? - SQL
How do I remove rows based off of cell value? - SQL
正在尝试看看是否有人可以提供帮助。
我正在尝试找到一种方法,让 SQL 识别任何列为铝的东西,然后删除与该品牌相关的所有行。因此,在 Coors 有铝的地方,它消除了所有 Coors 行。
样本:
Brand Alcohol Container
Absolute Vodka Glass
Absolute Vodka Plastic
Coors Beer Glass
Coors Beer Aluminum
Coors Beer Plastic
Gallo Wine Glass
Yellowtail Wine Glass
Yellowtail Wine Aluminum
Yellowtail Wine Plastic
Corona Beer Plastic
Corona Beer Glass
成品:
Brand Alcohol Container
Absolute Vodka Glass
Absolute Vodka Plastic
Gallo Wine Glass
Corona Beer Plastic
Corona Beer Glass
谢谢,
马特
您可以使用 not exists
:
select t.*
from mytable t
where not exists (
select 1
from mytable t1
where t1.brand = t.brand and t1.container = 'Aluminium'
)
正在尝试看看是否有人可以提供帮助。
我正在尝试找到一种方法,让 SQL 识别任何列为铝的东西,然后删除与该品牌相关的所有行。因此,在 Coors 有铝的地方,它消除了所有 Coors 行。
样本:
Brand Alcohol Container
Absolute Vodka Glass
Absolute Vodka Plastic
Coors Beer Glass
Coors Beer Aluminum
Coors Beer Plastic
Gallo Wine Glass
Yellowtail Wine Glass
Yellowtail Wine Aluminum
Yellowtail Wine Plastic
Corona Beer Plastic
Corona Beer Glass
成品:
Brand Alcohol Container
Absolute Vodka Glass
Absolute Vodka Plastic
Gallo Wine Glass
Corona Beer Plastic
Corona Beer Glass
谢谢, 马特
您可以使用 not exists
:
select t.*
from mytable t
where not exists (
select 1
from mytable t1
where t1.brand = t.brand and t1.container = 'Aluminium'
)