gpt4 book ai didi

mysql - 简单的sql查询返回零行

转载 作者:行者123 更新时间:2023-11-29 06:59:47 24 4
gpt4 key购买 nike

我的查询:

SELECT * FROM game_tbl WHERE ( `player_o` = 1 OR `player_x` = 1 ) AND ( `player_o` = NULL OR `player_x` = NULL )

game_tbl: enter image description here

使用:mysql

结果为零行,我想要“game1”。好吧,我想我可以使用其他查询,但是,对于我理解正确的错误 SQL 语法很重要,谢谢大家

最佳答案

尝试使用 IS NULL 而不是 = NULL,例如:

SELECT * 
FROM game_tbl
WHERE (`player_o` = 1 OR `player_x` = 1) AND (`player_o` IS NULL OR `player_x` IS NULL)

Here's MySQL 有关使用 NULL 值的文档。

To test for NULL, use the IS NULL and IS NOT NULL operators.

You cannot use arithmetic comparison operators such as =, <, or <> to test for NULL.

关于mysql - 简单的sql查询返回零行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43962779/

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