使用某些包含性条件获取所有数据时,例如列名等于“ blue”或“ yellow”而“ colorval”等于“ 100”时
> mysql> select * from Colors where colorname is not null;
+-----------+----------+
| colorname | colorval |
+-----------+----------+
| blue | 100 |
| blue | 200 |
| blue | 300 |
| red | 200 |
| red | 300 |
| red | 100 |
| red | 400 |
| yellow | 100 |
| yellow | 200 |
| yellow | 300 |
+-----------+----------+
我希望结果是
>
+-----------+----------+
| colorname | colorval |
+-----------+----------+
| blue | 200 |
| blue | 300 |
| red | 200 |
| red | 300 |
| red | 100 |
| red | 400 |
| yellow | 200 |
| yellow | 300 |
+-----------+----------+
答案 0 :(得分:1)
这是需要的条件:
select * from colors
where colorname is not null and (colorval <> 100 or colorname not in ('blue', 'yellow'))
您需要的是colorval不等于100,并且colorname不应该是同一行中的“ blue”,“ yellow”中的任何一个。
请参见demo。
结果:
| colorname | colorval |
| --------- | -------- |
| blue | 200 |
| blue | 300 |
| red | 200 |
| red | 300 |
| red | 100 |
| red | 400 |
| yellow | 200 |
| yellow | 300 |
如果只有这三种颜色,则可以这样简化:
select * from colors
where colorname is not null and (colorval <> 100 or colorname = 'red')
答案 1 :(得分:0)
因此您的查询应该是
a_threads = []
secondList = []
for k in range(20):
firstList = []
for n in range(0, 200):
thread = threading.Thread(target=functionA,args=(n, ))
thread.start()
a_threads.append(thread)
for thread in a_threads:
thread.join()
a_threads = []
thread = threading.Thread(target=functionB,args=(m, ))
thread.start()
a_threads.append(thread)
答案 2 :(得分:0)
select * from Colors where colorname is not null and (colorname ='blue' or colorname='yellow') and colorval <> 100;