gpt4 book ai didi

'with' 子句的 mySQL 版本

转载 作者:行者123 更新时间:2023-11-29 01:25:28 28 4
gpt4 key购买 nike

我的查询的目的是在数据库中搜索长字符串。为了加快此过程,longstring 表的所有记录在同一记录上都有该字符串的哈希值。我想首先找到表中搜索字符串的哈希值等于 longstring 表上的哈希值的所有记录。然后,在获得该数据集之后,我想比较实际的字符串(因为哈希值并不总是唯一的)。

现在在 oracle 或 mssql 中我会这样做...

with dataset as (
select long_string
from longstring
where hash = 'searchhash'
) select *
from dataset
where long_string = 'searchstring'

...但是 mysql 不支持 'with' 子句。那么 mysql 中我最好的选择是什么?

提前致谢!

最佳答案

您可以通过子选择来完成:

select *
from (
select long_string
from longstring
where hash = 'searchhash'
) AS dataset
where long_string = 'searchstring'

关于 'with' 子句的 mySQL 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1902964/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com