Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何显示适合客户的属性总数';什么样的标准?_Sql_Xampp - Fatal编程技术网

Sql 如何显示适合客户的属性总数';什么样的标准?

Sql 如何显示适合客户的属性总数';什么样的标准?,sql,xampp,Sql,Xampp,我的属性表包含propertyNo、street、city、postcode、type、rooms、rent、OwnerNo、staffNo和branchNo列 而我的客户机表有clientNo、fname、lame、tellNo、prefType和maxrent列 SELECT client.ClientNo, propertyforrent.PropertyNo,client.prefType, fname FROM client INNER JOIN propertyforren

我的属性表包含propertyNo、street、city、postcode、type、rooms、rent、OwnerNo、staffNo和branchNo列 而我的客户机表有clientNo、fname、lame、tellNo、prefType和maxrent列

SELECT client.ClientNo, propertyforrent.PropertyNo,client.prefType, fname
FROM client INNER JOIN
     propertyforrent
     ON propertyforrent.type = client.prefType                                            

我尝试了这个方法,但它没有返回与客户端prefType匹配的所有属性的总和

LEFT JOIN
将至少显示客户端以及属性是否与相关记录匹配

SELECT 
    x.ClientNo
  , y.PropertyNo
  , x.prefType
  , fname
FROM client x
LEFT JOIN propertyforrent y ON y.type = x.prefType
使用分组方式和计数

找出查询中的任何错误后,切换到
join

SELECT 
    x.ClientNo
  , x.prefType
  , COUNT(y.type) AS num_matches
FROM client x
JOIN propertyforrent y ON y.type = x.prefType
GROUP BY 
    x.ClientNo
  , x.prefType

左连接故障排除

LEFT JOIN
将至少显示客户端以及属性是否与相关记录匹配

SELECT 
    x.ClientNo
  , y.PropertyNo
  , x.prefType
  , fname
FROM client x
LEFT JOIN propertyforrent y ON y.type = x.prefType
使用分组方式和计数

找出查询中的任何错误后,切换到
join

SELECT 
    x.ClientNo
  , x.prefType
  , COUNT(y.type) AS num_matches
FROM client x
JOIN propertyforrent y ON y.type = x.prefType
GROUP BY 
    x.ClientNo
  , x.prefType
提示:
COUNT(*)
。提示:
COUNT(*)