我使用以下声明加入3个表
SELECT
c.FIRSTName, c.LASTName, r.feeOwe, r.paidorNotpaid, co.CITY, co.PERIOD, co.YEAR
FROM
CLIMBER c
JOIN
REGISTER r ON C.CLIMBERID = R.CLIMBERID
JOIN
COMPETITION co ON CO.COMPETITIONID = R.COMPETITIONID;
我得到了我需要的表格但是当我在下面的其他陈述时,它没有显示我想要的结果。任何人都可以启发我。
SELECT
c.FIRSTName, c.LASTName, r.feeOwe, r.paidorNotpaid, co.CITY, co.PERIOD, co.YEAR
FROM
CLIMBER c
JOIN
REGISTER r ON C.CLIMBERID = R.CLIMBERID
JOIN
COMPETITION co ON CO.COMPETITIONID = R.COMPETITIONID;
WHERE
co.CITY = 'dubai'
AND paidorNotpaid = null
AND City = 'Dubai'
AND Period = 'Summer'
AND YEAR = 2015;
答案 0 :(得分:1)
使用:
SELECT c.FIRSTName, c.LASTName, r.feeOwe, r.paidorNotpaid, co.CITY, co.PERIOD,co.YEAR
FROM CLIMBER c
JOIN REGISTER r
ON C.CLIMBERID = R.CLIMBERID
JOIN COMPETITION co
ON CO.COMPETITIONID = R.COMPETITIONID
WHERE co.CITY = 'dubai'
AND paidorNotpaid IS NULL
AND City = 'Dubai' -- probably you use the same condtion twice
AND Period = 'Summer'
AND YEAR = 2015;
paidorNotpaid = null
=> NULL
这就是为什么你没有得到任何记录。
不要将比较运算符与NULL
一起使用。要检查列值是否包含NULL
,请使用IS NULL
运算符
的 LiveDemo
强>
答案 1 :(得分:0)
如果您的数据库不区分大小写,请尝试:
SELECT c.FIRSTName, c.LASTName, r.feeOwe, r.paidorNotpaid, co.CITY, co.PERIOD,co.YEAR
FROM CLIMBER c
JOIN REGISTER r
ON C.CLIMBERID = R.CLIMBERID
JOIN COMPETITION co
ON CO.COMPETITIONID = R.COMPETITIONID
WHERE co.CITY = 'dubai'
AND r.paidorNotpaid IS NULL
AND co.Period = 'Summer'
AND co.YEAR = 2015;