0
SELECT
  People.Name, People.Secondname
  CONCAT(People.Name," ", People.Secondname)
FROM People, Shop, Circus
WHERE CONCAT(People.Name," ", People.Secondname) != Shop.Buyer 
  AND CONCAT(People.Name," ", People.Secondname) != Circus.Watcher

Ok, so this is my question. There are 2 columns. I have concat'ed them and want to find list of people who havent been in Shop AND Circus. Like: I have concated full name - "Jhon Jhonson". He havent been in circus and havent been in shop. So i want him to be shown.

Becouse I cant publish picture here, at least i can get link of table i am trying to make... http://imm.io/1k5tJ I hope you can decipher what I want to say.

4

2 回答 2

0

尝试

SELECT
  People.Name, People.Secondname
  CONCAT(People.Name," ", People.Secondname)
FROM People left outer join Shop on CONCAT(People.Name," ", People.Secondname) = Shop.Buyer 
left outer join Circus on  CONCAT(People.Name," ", People.Secondname) = Circus.Watcher
where Shop.Buyer is null and  Circus.Watcher is null
于 2013-11-07T21:10:41.800 回答
0

根据您上面的评论:“我想查找在 Concated 列中的人,但不在用户中而不是在参与者中”,然后此查询将让您选择用户和参与者中不存在的所有 tbl1 数据分别是二级和三级表。

select
  tbl1.name,
  tbl1.name2
from People tbl1
  left join Show1 tbl2 on tbl1.name = tbl2.user
  left join Show2 tbl3 on tbl1.name2 = tbl3.participant
where tbl2.user is null
  and tbl3.participant is null

我认为您对问题的描述仍然不清楚,但这是朝着正确方向迈出的一步。

更新: 根据您对问题的评论更改列名。

于 2013-11-07T18:49:55.157 回答