SQL 显示查询的反向过滤器。 "显示 xtable 中的字段,其中 Field = xFieldnameA = a AND Field = xFieldnameB

发布于 2024-12-28 02:11:46 字数 560 浏览 3 评论 0 原文

这涉及 sql show 查询。下面的查询有效,问题是我似乎必须告诉mysql我不想要哪些字段名称,而不是我想要的字段名称(这是首选)。

例如(工作)

SHOW FIELDS FROM users WHERE Field != 'uid' AND Field != 'fk_Utype'

上面的内容按照预期完美执行,从结果集中去掉了“uid”和“fk_Utype”。但是,当查询我只想按哪些列(如传统的选择查询)列出所需的列名称时,其行为并不符合预期。

SHOW FIELDS FROM users WHERE Field = 'firstName' AND Field = 'lastName'

我希望上面的查询只返回两个指定的列。但是,查询会产生空结果集(列确实存在于该表中,并在执行上述查询时出现)。显然我没有正确列出所需的列名称。正如在 Select 语句中一样,语法只是“Select col1, col2”,但此语法在 SHOW 查询中是不正确的(尽管我很可能是错误的)。

This concerns sql show queries. The following query below works the issue is it seems I must tell mysql which field names I don't want rather than those I do (which is preferred).

e.g. (working)

SHOW FIELDS FROM users WHERE Field != 'uid' AND Field != 'fk_Utype'

The above executes perfectly as expected, stipping off both 'uid' and 'fk_Utype' from the result set. However when querying by which columns I only want (like a traditional Select query) listing the column names needed does not behave as expected.

SHOW FIELDS FROM users WHERE Field = 'firstName' AND Field = 'lastName'

I expected the above query to simply return the two specified columns. However, the query instead results in an empty result set (the columns do exist in that table and appear when the above query is executed). Clearly I'm not listing the desired column names correctly. As in a Select statement the syntax it simply 'Select col1, col2' but this syntax is incorrect in a SHOW query (though I may well be mistaken).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝影如岚 2025-01-04 02:11:46
SHOW FIELDS FROM users WHERE Field = 'firstName' OR Field = 'lastName'

AND 表示两个条件都必须为真,而 OR 表示任一条件都可以为真。

SHOW FIELDS FROM users WHERE Field = 'firstName' OR Field = 'lastName'

AND means both conditions must be true whereas OR means either condition can be true.

忆悲凉 2025-01-04 02:11:46

尝试下面的查询

SHOW FIELDS FROM users WHERE Field == 'firstName' AND Field == 'lastName'

祝你好运!

Try below query

SHOW FIELDS FROM users WHERE Field == 'firstName' AND Field == 'lastName'

Good Luck!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文