这个sql语句该如何修改下

WBOY
Release: 2016-06-13 13:47:53
Original
907 people have browsed it

这个sql语句该怎么修改下?

SQL code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->SELECT si.user_id FROM ecs_store_info AS si WHERE si.store_name like (SELECT wl.store_name FROM ecs_wpaqq_log AS wl WHERE wl.lngShopId=0)
Copy after login
就是如何在like关键后使用select语句

------解决方案--------------------
LZ的想法我大致明白,但是like是模糊匹配一串字符。LZ如果是想在很多个字符里面,随便模糊匹配任意一个,只能用in或者通过PHP遍历结果然后重新sql,这个目前没见过如何在一条sql里面实现的,不过应该有大神能做到吧,这我就不清楚了。
------解决方案--------------------
用下面这句,我在Oracle里面测试是可以的:
select * from users u where u.name like '%'||(select name from users where id=1)||'%';
------解决方案--------------------
LS,如果子查询中只能取出唯一一条数据,那么LZ的问题就不是问题了。

问题的关键就在于他LIKE中匹配的是个结果集...我刚才查了下,mysql中的函数也没有能模糊匹配一串字符

的,LZ你放弃吧,最好换写法,因为就算用sql语句实现了,效率也会出奇的底下。
------解决方案--------------------
探讨
SQL code
SELECT si.user_id FROM ecs_store_info AS si WHERE si.store_name like (SELECT wl.store_name FROM ecs_wpaqq_log AS wl WHERE wl.lngShopId=0)
就是如何在like关键后使用select语句
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