-1

我有

tbl_ticket_categories(id , category_name , description , site_referers_id)

tbl_ticket_repliers(id , user_id , category_id , site_referers_id)

tbl_users(id , role_id , username , password )

我想从哪里全category_namedescriptiontbl_ticket_categoriessite_referers_id = 1

还有username那些user_idtbl_ticket_repliers.

4

2 回答 2

1
select category_name,description,username from tbl_ticket_categories as ttc
join tbl_ticket_repliers as ttr on ttr.category_id=ttc.id
join tbl_users as tu on tu.id=ttc.user_id
where site_referers_id = 1

这是您获得确切结果的查询检查一次

于 2012-07-28T10:34:58.927 回答
0
SELECT category_name, description, tu.username 
   FROM tbl_ticket_categories tc 
     INNER JOIN tbl_ticket_repliers tr 
        ON tc.id = tr.category_id
     INNER JOIN tbl_users tu 
        ON tr.user_id = tu.id
   WHERE tc.site_referers_id = 1

看到这个小提琴

于 2012-07-28T10:32:15.793 回答