这里是 SQL 新手。
我有这个架构:
我需要简单的英语是:
“在 2 列中,将一列放在另一列上方,然后计算有多少个不同值”
我已经尝试过
SELECT COUNT (DISTINCT uid ) from nodes UNION SELECT COUNT (DISTINCT uid) from ways ;
SELECT distinct nodes.uid from nodes JOIN ways on nodes.uid = ways.uid ;
sqlite> SELECT COUNT (DISTINCT uid ) from nodes UNION SELECT COUNT (DISTINCT uid) from ways ;
1195
2182
sqlite> SELECT uid from nodes FULL OUTER JOIN ways on nodes.uid = ways.iud ;
Error: RIGHT and FULL OUTER JOINs are not currently supported
SELECT COUNT (DISTINCT iud) FROM (SELECT DISTINCT uid from nodes as uid UNION SELECT DISTINCT uid from ways as uid as subq);
SELECT count (distinct nodes.uid) from nodes JOIN ways on nodes.uid = ways.uid ;
需要很长时间,我不确定nodes.uid =ways.uid是正确的方法
有什么想法吗?
最佳答案
我想我明白了
SELECT COUNT (DISTINCT uid) from (SELECT DISTINCT uid from nodes UNION SELECT DISTINCT uid from ways) as subq ;
关于mysql - 在多个表sql中的同一列上选择不同的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40900230/