gpt4 book ai didi

Mysql 表名带有字符串连接?

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

我想选择所有表名包含另一个字段名的表

喜欢

Show Tables Like  '%' + table.table_name_prefex

但这给了我一个错误。

[Err] 1064 - You have an error in your SQL syntax; check the

manual that corresponds to your MySQL server version for the right syntax to use near '+table.table_name_prfex' at line 1

最佳答案

有点暗示要么非常聪明,要么非常愚蠢的模式。

你不能用“SHOW”来做到这一点 - 正如 Haim Evgi(POST 已删除)所说,你需要使用信息模式。

I want to select all those table which is begin from fields in another db

所以只需加入...

SELECT t.table_schema
, t.table_name
FROM INFORMATION_SCHEMA.TABLES t
, otherdb.table o
WHERE t.table_name LIKE CONCAT('%',o.table_name_prefex)
AND .... /* filters to select rows from otherdb.table */

如果您的表格确实名为表格,那么您需要将其括在反引号中。

关于Mysql 表名带有字符串连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7400810/

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