WHERE
我需要SQL Server 中条件子句的解决方案。我不知道如何WHERE
根据声明的变量将函数添加到子句中。我将用所需的逻辑括起来条件部分
DECLARE @distance bigint
DECLARE @photosneeded bigint
SET @distance * 50
SELECT * FROM users u
WHERE
[IF @distance > 0 THEN distance_function(lat1,lon1,lat2,lon2)<=@distance END]
AND
[IF @photosneeded>0 THEN u.photo IS NOT NULL AND u.photo <>'' END]