gpt4 book ai didi

mysql - 保存坐标 X,Y - 查找孔 MySql

转载 作者:行者123 更新时间:2023-11-30 00:42:25 25 4
gpt4 key购买 nike

我目前正在创建一个模式,用户可以选择某些“框”,并将其作为 X,Y 点保存在数据库中。 (当前存储为简单整数)。

即第 1 行第 2 列将是 x:1 y:2

如何找到数据库中的第一个“空/可用”位置?

即如果第 1-3 行中的所有列都被采用,则答案应为 X: 4, Y:1。

提前致谢

最佳答案

类似这个函数(将 mx_rows、mx_cols 作为参数):

set @i := 0;
set @j := 0;
set @tmp := 0;

while @i < @mx_rows DO
set @j := 0;
while @j < @mx_cols DO
@tmp := select count(*) from POINTS
where x = @j and y = @i;
if @tmp == 0 then
return (@j, @i);
end if;
set @j = @j + 1;
end while;
set @i = @i + 1;
end while;

关于mysql - 保存坐标 X,Y - 查找孔 MySql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21656409/

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