这和MYSQL查询中的JOIN一样吗?
这是我的疑问:
这看起来有效吗?使用 JOIN 有优势吗?或者说这也是一样的吗?
$query_Recordset2 =
"SELECT cute_news.category, cute_news.id, cute_story.short, cute_story.post_id, cute_news.date, cute_news.url, cute_news.title
FROM cute_news, cute_story
WHERE cute_news.id = cute_story.post_id AND category LIKE '10%'
ORDER BY date DESC LIMIT 0,35";
Here is my query:
Does this look efficient? Is there an advantage of using JOIN? Or is this the same?
$query_Recordset2 =
"SELECT cute_news.category, cute_news.id, cute_story.short, cute_story.post_id, cute_news.date, cute_news.url, cute_news.title
FROM cute_news, cute_story
WHERE cute_news.id = cute_story.post_id AND category LIKE '10%'
ORDER BY date DESC LIMIT 0,35";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题可能与那个问题重复< /a>.
隐式 JOIN 不包含意图,因此可读性较差。
您的查询将产生与以下完全相同的结果:
但后一个查询的可读性要高得多,因为您将 JOIN 谓词与过滤器分开并表达了查询背后的逻辑。
This question might be a duplicate of that one.
Implicit JOINs do not carry the intent, and are thus less readable.
Your query will lead to strictly same results as:
but the latter query is far more readable because you separate JOIN predicates from filters and express the logic behind the query.
因此,它指定了交叉连接,并且 WHERE 子句可以应用来自 wikipedia
换句话说,都是一样的
from wikipedia
In other words it's the same
如果您的意思是
FROM
子句具有多个以逗号分隔的表,那么是的,它与INNER JOIN
基本相同。然而,这是旧语法;优先使用
INNER JOIN
,这是更标准的。此外,旧语法的问题在于,通过将连接字段与 WHERE 子句的其余部分组合起来,可能会使查询难以阅读,并且在某些情况下会导致解析器承担额外的工作。最好在每个
JOIN
的ON
子句中明确说明关系。If you mean the
FROM
clause having multiple tables, comma-separated, then yes, it is basically the same as anINNER JOIN
.However, this is old syntax; it is preferred to use
INNER JOIN
, which is more standard.In addition, the problem with the old syntax is that by combining the joining fields with the rest of the
WHERE
clause, it can make the query hard to read, and in some cases cause extra work for the parser. It is much better to explicitly state the relationships in theON
clause for eachJOIN
.