This article describes how to match fields in multiple MySQL tables. For example, the name in the tag table matches the name in info. For more information, see
This article describes how to match fields in multiple MySQL tables. For example, the name in the tag table matches the name in info. For more information, see
The Code is as follows:
$ SQL = $ empire-> query ("select table. title, lianxi, table. dizhi, table. id from table, table1 where table1.sid like concat ('% |', table. id, '| %') and table1.id = ". $ navinfor [id]. "");
While ($ r = $ empire-> fetch ($ SQL ))
{
$ Title = $ r ['title'];
$ Lianxi = $ r ['liance'];
$ Dizhi = $ r ['dizhi'];
}
The two tables info and tag are as follows:
Info table
Id name
1 aa and bb
2 bb and cc
3 ee and dd
Tag table
1 aa
2 bb
The name in the tag table matches the name in info.
In this case, there is a problem:
The Code is as follows:
Select info. id, info. name from tag, info where info. name like '%' + tag. name + '%'
Correct:
The Code is as follows:
Select info. id, info. name from tag, info where info. name like concat ('%', tag. name, '% ')