USE SPJ;

-- ①
SELECT SNO FROM SPJ WHERE JNO='J1';

-- ②
SELECT SNO FROM SPJ WHERE JNO='J1' AND PNO='P1';

-- ③
SELECT SPJ.SNO
FROM SPJ
JOIN P ON SPJ.PNO = P.PNO
WHERE SPJ.JNO = 'J1' AND P.COLOR = '红';

-- ④
SELECT SPJ.JNO
FROM SPJ
JOIN S ON SPJ.SNO=S.SNO
JOIN P ON SPJ.PNO=P.PNO
WHERE P.COLOR!='红' AND S.CITY!='天津';