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

php联表取值问题

WBOY
Release: 2016-06-23 14:00:43
Original
960 people have browsed it

表1                                                               表2

id                                                                   id              txt

#1,#2,                                                            1              标签1

                                                                        2              标签2



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


不知道各位明白我的意思没, 就是 表1 id 的 #1,值 #和,之间的数字 对应表2的id数字 然后取得表2的txt值。这样的需求该怎么做呢?


回复讨论(解决方案)

SELECT * FROM 表1 LEFT JOIN 表2 ON 表2.id in (REPLACE(表1.id, '#', ''))
Copy after login
Copy after login

SELECT * FROM 表1 LEFT JOIN 表2 ON 表2.id in (REPLACE(表1.id, '#', ''))
Copy after login
Copy after login



我只想说:  你叼!      头像是个多么甜美的妹子啊。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template