Table 1
+-------+--------+--------+ | name | age | gender | +-------+--------+--------+ | mark | 20 | male | | john | 22 | male | | jenny | 21 | female | +-------+--------+--------+
Table 2
+-------+----------+---------+ | name2 | status | address | +-------+----------+---------+ | john | single | miami | | mark | single | new york| | jenny | single | jersy | +-------+----------+---------+
I would like to display like this...
for Mark example:
Name: Mark
Age: 20
Gender: Male
Status: single
address: newyork
PLEASE USE "LIKE" not equal
我想这样显示......对于马克的例子:名字:马克年龄:20性别:男状态:单一地址:newyork请使用“LIKE”不等于
1 个解决方案
#1
1
Basically, =
is much preferred to use over LIKE
because LIKE
is used for pattern matching.
基本上,=更喜欢使用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
To further gain more knowledge about joins, kindly visit the link below:
要进一步了解联接,请访问以下链接:
- Visual Representation of SQL Joins
SQL连接的可视化表示
if you really want to use LIKE
,
如果你真的想用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
- SQLFiddle Demo (both queries)
SQLFiddle演示(两个查询)
#1
1
Basically, =
is much preferred to use over LIKE
because LIKE
is used for pattern matching.
基本上,=更喜欢使用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
To further gain more knowledge about joins, kindly visit the link below:
要进一步了解联接,请访问以下链接:
- Visual Representation of SQL Joins
SQL连接的可视化表示
if you really want to use LIKE
,
如果你真的想用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
- SQLFiddle Demo (both queries)
SQLFiddle演示(两个查询)