gpt4 book ai didi

mysql - 这两个 SQL 语句有何不同?

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

1:

$query = mysql_query("
SELECT table_one.row
FROM table_one
INNER JOIN table_two
ON table_two.row = $id");

2:

$query = mysql_query("
SELECT table_one.row
FROM table_one, table_two
WHERE table_two.row = $id");

这只是同一事物的两种写法吗?

最佳答案

他们都取得了相同的结果,但采用了不同的方法。尽管您滥用了 ON 子句。

我会建议这样的事情:

$query = mysql_query("
SELECT table_one.row
FROM table_one
INNER JOIN table_two
ON table_one.id = table_two.id
WHERE table_two.row = $id");

引自 mysql 站点:

The conditional_expr used with ON is any conditional expression of the form that can be used in a WHERE clause. Generally, you should use the ON clause for conditions that specify how to join tables, and the WHERE clause to restrict which rows you want in the result set.

关于mysql - 这两个 SQL 语句有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5481546/

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