table1
id | 1
supplier | 1
额外信息表:
table2
id | 1
supplier | 1
extrainfo | "Best information"
查询
SELECT
table1.*,table2.*
FROM
mytable_normalinfo as table1,
mytable_extrainfo as table2
WHERE
MATCH(table1.fulltextcollum)
AGAINST ('+test*' IN BOOLEAN MODE)
AND
table1.supplier = table2.supplier
AND
table1.id = table2.id
LIMIT 10;
答案 0 :(得分:4)
我想你只想要left join
:
SELECT table1.*, table2.*
FROM mytable_normalinfo as table1 LEFT JOIN
mytable_extrainfo as table2
ON table1.supplier = table2.supplier AND
table1.id = table2.id
WHERE MATCH(table1.fulltextcollum) AGAINST ('+test*' IN BOOLEAN MODE)
LIMIT 10;
两个注释:
JOIN
语法。简单规则:从不在FROM
子句中使用逗号。LIMIT
时,通常也会使用ORDER BY
。