我有两张桌子:
tb_doc
:
===========================================
| id | document_title | document_summary |
===========================================
| 1 | a data mining | document_summary1 |
| 2 | B | document_summary2 |
===========================================
tb_wrap
:
============================================
| id | data_url | data_title | doc_url |
===========================================
| 1 |data_url1 | B | doc_url1 |
| 2 |data_url2 | a data mining | doc_url2 |
============================================
我想加入2个表中document_title
= data_title
(匹配2个字符串)的数据,所以我会得到如下结果:
data_title <href data_url>
doc_url
document_summary
这是查询:
SELECT * from tb_wrap as a
JOIN (
SELECT document_title, document_summary from tb_doc) as b`
ON a.data_title LIKE b.document_title
如何获得它们?谢谢你:))
答案 0 :(得分:3)
JOIN
条件应为=
而不是LIKE
。我认为没有必要加入一个子查询。这只是一个基本的INNER JOIN
。
SELECT
tb_wrap.data_url,
tb_wrap.data_title
tb_wrap.doc_url,
tb_doc.document_summary
FROM
tb_doc
INNER JOIN tb_wrap ON tb_doc.document_title = tb_wrap.data_title