SQL子查询 语法:
sno in (SELECT sno FROM p_test WHERE category =“800米” )
WHERE category=“立定跳远” and sno in (SELECT sno FROM p_test WHERE category =“800米” )
上述语句的意思就是2个条件,类型是立定跳远,学号是类型为800米的所有学号
SQL LEFT JOIN 语法:
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
实例:
SELECT sno,category,
b.dict_value weight
from p_test a
LEFT JOIN (
SELECT
dict_id,
dict_value
FROM
pe_weight
WHERE
dict_category=‘体重’
) b on a.sno=b.dict_id
WHERE category=“身高” AND sno in (SELECT sno from p_test where category=“1000米” )
两张表之间要有共同的字段内容on a.sno=b.dict_id