select
tb_pay_detail.pay_id,
tb_pay_detail.pay_amount,
tb_pay_detail.pay_price,
tb_pay.pay_date,
tb_pay.book_id,
(select tb_user.nameuser from tb_user as tb1 where tb_user.iduser=tb_pay.beg_user_receive) as user_receive,
(select tb_user.nameuser from tb_user as tb2 where tb_user.iduser=tb_pay.pay_user_pay) as user_receive,
tb_department.dep_name
from tb_pay_detail
inner join tb_pay on tb_pay_detail.pay_id=tb_pay.pay_id
inner join tb_department on tb_pay.dep_id=tb_department.dep_id
ผมอยากได้คือ ตรง
Code
(select tb_user.nameuser from tb_user as tb1 where tb_user.iduser=tb_pay.beg_user_receive) as user_receive,
(select tb_user.nameuser from tb_user as tb2 where tb_user.iduser=tb_pay.pay_user_pay) as user_receive,
select
tb_pay_detail.pay_id,
tb_pay_detail.pay_amount,
tb_pay_detail.pay_price,
tb_pay.pay_date,
tb_pay.book_id,tb_pay.pay_user_pay,tb_pay.beg_user_receive,
(select tb_user.nameuser from tb_user as tb1 where tb_user.iduser=tb_pay.beg_user_receive) as user_receive,
(select tb_user.nameuser from tb_user as tb2 where tb_user.iduser=tb_pay.pay_user_pay) as user_receive,
tb_department.dep_name
from tb_pay_detail
inner join tb_pay on tb_pay_detail.pay_id=tb_pay.pay_id
inner join tb_department on tb_pay.dep_id=tb_department.dep_id