Issue: join doesn't works
Author: zhangmaohong
State: closed
Created: 2018-08-15 10:31:55

```class BaseModel(Model):
    class Meta:
        database = db

    def __str__(self):
        r = {}
        for k in self.__data__.keys():
            try:
                r[k] = str(getattr(self, k))
            except:
                r[k] = json.dumps(getattr(self, k))
        # return str(r)
        return json.dumps(r, ensure_ascii=False)


class Sohu_Jieshaoye(BaseModel):
    sohu_jsy_id = IntegerField(primary_key = True)
    intro_url = CharField()
    intro_title = CharField() 
    primary_key_j = CharField(index = True)
    intro_pid = CharField()
    video_name = CharField(index = True)
    description = TextField()
    label = CharField()
    district = CharField()
    episodes = CharField()
    release_time = CharField()
    director = CharField()
    actor = CharField()
    pv = CharField()

class Sohu_Bofangye(BaseModel):
    sohu_bfy_id = IntegerField(primary_key = True)
    bofangye_url = CharField()
    bofangye_title = CharField(index = True)
    primary_key = CharField(index = True)
    pid = CharField(index = True)
    vid = CharField(index = True)
    duration = CharField()
    crumb = CharField()
    type = CharField()
    mark_vip = CharField()
```


``` 
   queryBoFang = queryBoFang.where(sohu_bofang_model.bofangye_title.contains(video_name_kw))
   queryJieshao = queryJieshao.where(sohu_jieshao_model.video_name.contains(video_name_kw))
   query = (
            queryBoFang
            .select(queryBoFang,queryJieshao)
            .join(
                queryJieshao,
                JOIN.LEFT_OUTER,
                on=(queryBoFang.c.primary_key == queryJieshao.c.primary_key_j),
                attr='jieshao'   
                )
        .union_all(
            queryBoFang
            .select(queryBoFang,queryJieshao)
            .join(
                queryJieshao,
                JOIN.RIGHT_OUTER,
                on=(queryBoFang.c.primary_key == queryJieshao.c.primary_key_j),
                attr='jieshao'
                )
            .where(queryBoFang.c.primary_key == None)
        )
        )
```

From your issue it's unclear what the problem is, what the expected result/output should be, etc.

Can you please add a comment indicating what the problem is? Also, if you could please create a minimal example -- the models you've included are difficult to read.

I'll reopen the issue upon receiving a comment.

```
example model:
class t1(BaseModel):
    name =  CharField() 
    intro_title = CharField() 
    primary_key = CharField(index = True)
class t2(BaseModel):
    name =  CharField() 
    primary_key = CharField(index = True)
    director = CharField()
    actor = CharField()
```

My main requirement is to judge whether t1.name and t2.name contain the keyword according to the keyword input by the user. If it is included, the content that matches t1 and t2 is combined and output.
T1 and t2 can be combined by  primary_key.

my query:
```
 queryt1 = t1.where(t1.name.contains(kw))
 queryt2 = t2.where(t2.name.contains(kw))
 query = ((queryt1
.select(queryt1, queryt2)
.join(queryt2, JOIN.LEFT_OUTER, on= queryt1.primary_key == queryt2.primary_key))
union_all
(queryt1
.select(queryt1, queryt2)
.join(queryt2, JOIN.RIGHT_OUTER, on= queryt1.primary_key == queryt2.primary_key))
.where(queryt1.primary_key == None))
```

But my output is only t1 content, no t2 content


            

Your query is all sorts of wrong... I'd suggest posting to stackoverflow.