我正在尝试运行以下查询。由于某种原因,我需要加入不同的表,其中包括所有表的结果。
假设查询是:
Traceback (most recent call last):
File "./twitter_scraper.py", line 29, in <module>
twint_scrape(username, username)
File "./twitter_scraper.py", line 20, in twint_scrape
twint.run.Search(c)
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\run.py", line 201, in Search
run(config)
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\run.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File "C:\Users\seant\Anaconda3\lib\asyncio\base_events.py", line 573, in run_until_complete
return future.result()
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\run.py", line 121, in main
await self.tweets()
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\run.py", line 97, in tweets
await self.Feed()
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\run.py", line 40, in Feed
response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\get.py", line 58, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=headers)
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\get.py", line 89, in Request
return await Response(session, url, params)
File "C:\Users\seant\Anaconda3\lib\site-packages\twint\get.py", line 94, in Response
async with session.get(url, ssl=False, params=params) as response:
File "C:\Users\seant\Anaconda3\lib\site-packages\aiohttp\client.py", line 1005, in __aenter__
self._resp = await self._coro
File "C:\Users\seant\Anaconda3\lib\site-packages\aiohttp\client.py", line 497, in _request
await resp.start(conn)
File "C:\Users\seant\Anaconda3\lib\site-packages\aiohttp\client_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "C:\Users\seant\Anaconda3\lib\site-packages\aiohttp\streams.py", line 588, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054] 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다
假设上述查询的结果是:
Select a.value1, b.value2, c.value3
from a
join b on a.some_value = b.some_value1
join c on c.Some_other_value = b.some_diff_value
where (my conditions)...
我想从上述结果集中删除value1不是1的值。
预期输出:
value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
2 | othr1 | othr2
3 | diff2 | diff3
postgresql中有什么方法可以实现这一目标?搜索了不同的主题,但没有其他任何线索。任何建议表示赞赏。
注意:我不能使用value1 | value2 | value3
-------+--------+--------
1 | val1 | val2
1 | some1 | some2
,因为SQL查询中的逻辑将导致一些数学记录丢失。因此,整个想法是按原样运行SQL查询,但在执行Select操作后删除记录,并仅将结果与where a.value1 = 1
一起使用。
答案 0 :(得分:0)
使用子查询,然后在where子句中过滤a.value1=1
select * from
(
Select a.value1,b.value2,c.value3
from a join b on a.some_value=b.some_value1
join c on c.Some_othr_value=b.some_diff_value
where your conditions
)AA where a.value1=1