gpt4 book ai didi

php - MySQL 查询难题

转载 作者:行者123 更新时间:2023-11-29 03:49:27 25 4
gpt4 key购买 nike

我有一个包含两个字段(id 和 word)的表。谁能告诉我为什么:

$query0 = "SELECT * FROM words WHERE id IN ($treated_words) ";

是一个有效的查询。但是:

$query0 = "SELECT * FROM words ORDER BY id ASC WHERE id IN ($treated_words) ";

不是。非常感谢

最佳答案

SQL 查询中元素的顺序很重要。 ORDER BY 子句必须出现在 WHERE 子句之后。

查看 MySql 文档以了解语法规则。你会看到类似的东西

SELECT [ DISTINCT | ALL ]
column_expression1, column_expression2, ....
[ FROM from_clause ]
[ WHERE where_expression ]
[ GROUP BY expression1, expression2, .... ]
[ HAVING having_expression ]
[ ORDER BY order_column_expr1, order_column_expr2, .... ]

关于php - MySQL 查询难题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1934318/

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