Home >Backend Development >PHP Tutorial >php联表取值有关问题

php联表取值有关问题

WBOY
WBOYOriginal
2016-06-13 11:51:25782browse

php联表取值问题
表1                                                               表2

id                                                                   id              txt

#1,#2,                                                            1              标签1

                                                                        2              标签2



SELECT * FROM 表1 LEFT JOIN 表2 ON 表1.id=表2.id 


不知道各位明白我的意思没,  就是 表1 id 的 #1,值 #和,之间的数字  对应表2的id数字  然后取得表2的txt值。这样的需求该怎么做呢?
------解决方案--------------------
SELECT * FROM 表1 LEFT JOIN 表2 ON 表2.id in (REPLACE(表1.id, '#', ''))

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn