我有2张桌子。我的表结构是这样的:任何人都可以帮助我在这里做什么?
Table 'customer'
(
cust_id (PK),
cust_name,
cust_balance
);
and Table 'account'
(
acc_id (PK),
cust_id(FK) --relating to customer table
);
客户数据:
name cust_id
scott c100
ford c200
帐户数据:
scott personal a100
scott joint a300
ford personal a200
ford joint a300
那么什么会在帐户表的cust_id列的值?如果我输入斯科特的身份证,那么在查询时会显示只有斯科特有2个账户,但事实并非如此,福特也有2个账户。那么,我该如何做到这一点?
你到底想达到什么目的?您是否想要为每位客户计算帐户数量?你说你“输入”斯科特的身份证,然后找回斯科特的两个账户,当通过斯科特身份证查询账户时,这不是期望的结果吗? –