我想查询2个表。

表结构如下:

常问问题

faq_id | member_id | answer


工人

id | faq_id | owner1 | owner2


我在这里尝试做的是:

SELECT faqs.*, workbasket.* FROM faqs
INNER JOIN workbasket
WHERE faqs.member_id = 1
AND workbasekt.owner1 = 1 OR workbasekt.owner2 = 1

最佳答案

像这样吗

SELECT FAQ.*, workers.* FROM FAQ INNER JOIN workers on FAQ.faq_id = workers.faq_id
WHERE FAQ.member_id = 1 AND (workers.owner1 = 1 OR workers.owner2 = 1)


您需要更具描述性,并说明要返回的列,要从中获取信息的表以及应如何将这些表连接在一起。

关于mysql - MySQL Query 2表无关列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11634969/

10-16 23:41