从存储过程输出JOINS的不同值

时间:2016-02-03 12:40:54

标签: mysql sql join stored-procedures distinct

使用StackOverflow中的SQL JOIN示例What is the difference between "INNER JOIN" and "OUTER JOIN"?

想知道这是否是从Store-procedure返回的,如何从下面的示例中返回不同的值名称和电话号码。即使我创建了一个XML字符串,即使这样我也无法选择DISTINCT值。有什么帮助吗?

select name, phone, selling 
from people join property 
on people.pid = property.pid;

+-----------+--------------+----------------------+
| name      | phone        | selling              |
+-----------+--------------+----------------------+
| Mr Brown  | 01225 708225 | Old House Farm       |
| Mr Pullen | 01380 724040 | The Willows          |
| Mr Pullen | 01380 724040 | Tall Trees           |
| Mr Pullen | 01380 724040 | The Melksham Florist |
+-----------+--------------+----------------------+

1 个答案:

答案 0 :(得分:-1)

实际上有点不清楚

但是,如果你喜欢这样的话 Select distinct name,phone from people join property on people.pid = property.pid;

你会得到的 Mr Brown | 01225 708225 | | Mr Pullen | 01380 724040