关于SQL子查询的一个问题

今天在翻看工具书的时候,发现了一个sql语句:

select 
    cust_name, 
    cust_state, 
    (select count(*)
     from  orders
     where orders.cust_id = customers.cust_id) as orders
from customers
order by cust_name;

 

在子查询中居然可以直接使用外部的customers表中的cust_id字段进行where条件限制,瞬间就感觉到好像哪里不对劲。

真的可以这样写吗?明天到环境上执行一下看看就知道了。