select 姓名身份证号 from 人员住宿 where 身份证号住宿=身份证号人员 and date入住时间=select date入住时间 from 住宿 where 身份证号住宿=320911197005235; 报错ERROR 1052 23000 at line 1 Column 身份证号 in field list is ambiguous帮我检查一下
在这个查询中,出现了两个表都有“身份证号”这个字段,所以需要明确指定要查询的是哪个表的字段。可以将查询语句改为:
SELECT 人员.姓名, 人员.身份证号 FROM 人员, 住宿 WHERE 住宿.身份证号=人员.身份证号 AND date(入住时间) = (SELECT date(入住时间) FROM 住宿 WHERE 身份证号="32091119700523***5");
这样就可以避免“Column '身份证号' in field list is ambiguous”的错误了。
原文地址: http://www.cveoy.top/t/topic/fn8z 著作权归作者所有。请勿转载和采集!