这涉及 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).
发布评论
评论(2)
AND 表示两个条件都必须为真,而 OR 表示任一条件都可以为真。
AND means both conditions must be true whereas OR means either condition can be true.
尝试下面的查询
祝你好运!
Try below query
Good Luck!!!