表1
+-------+--------+--------+ | name | age | gender | +-------+--------+--------+ | mark | 20 | male | | john | 22 | male | | jenny | 21 | female | +-------+--------+--------+
表2
+-------+----------+---------+ | name2 | status | address | +-------+----------+---------+ | john | single | miami | | mark | single | new york| | jenny | single | jersy | +-------+----------+---------+
我想这样显示...
对于马克的例子:
姓名:马克
年龄:20
性别:男
现状:单身
地址:newyork
请使用“LIKE”不等于
答案 0 :(得分:1)
基本上,=
比LIKE
优先使用,因为LIKE
用于模式匹配。
SELECT a.name, a.age, a.gender,
b.status, b.address
FROM table1 a
INNER JOIN table2 b
ON a.name = b.name2
要进一步了解联接,请访问以下链接:
如果你真的想使用LIKE
,
SELECT a.name, a.age, a.gender,
b.status, b.address
FROM table1 a
INNER JOIN table2 b
ON a.name LIKE b.name2