非 id 多对多关联模型怎样定义
多对多的情况下怎样指定外键呢
select question_paper
.*, baby_customer
.customer_code
as pivot_customer_code
, baby_customer
.baby_code
as pivot_baby_code
from question_paper
inner join baby_customer
on question_paper
.id
= baby_customer
.baby_code
where baby_customer
.customer_code
in ('1748')
这里的1748 是user表的id,但是并不是用user.id进行关联的,而是用user.customer_code关联的
有没有人知道该怎样写
推荐文章: