时间:2021-07-01 10:21:17 帮助过:16人阅读
请问加个%是啥意思
没有错
但我绝不相信你的表中有 (select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)... 这样的字符串
没有错
但我绝不相信你的表中有 (select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)... 这样的字符串
版主,您错了.
(select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)是绝对正确的.也有这样的字符串.
问题己解决,附上答案:
SELECT * FROM eload_goods WHERE goods_sn LIKE (SELECT CONCAT(LEFT(goods_sn,9),'%') AS goods_sn FROM eload_goods WHERE goods_id = 126300 LIMIT 1)
我错在哪?
select * from eload_goods where goods_sn like '(select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)%'
不知字符串吗
SELECT * FROM eload_goods WHERE goods_sn LIKE (SELECT CONCAT(LEFT(goods_sn,9),'%') AS goods_sn FROM eload_goods WHERE goods_id = 126300 LIMIT 1)
这样的sql不蛋疼吗?
我错在哪?
select * from eload_goods where goods_sn like '(select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)%'
不知字符串吗
MYSQL的子查询不支持limit,应该是limit 1导致的错误吧
如果goods_id是主键的话,limit 1完全没有必要,而且不被支持
错误的原因在于单引号,单引号中的内容并没有进行查找,而是直接将引号内容区匹配了
SELECT * FROM eload_goods WHERE goods_sn LIKE (SELECT CONCAT(LEFT(goods_sn,9),'%') AS goods_sn FROM eload_goods WHERE goods_id = 126300 LIMIT 1)
这样的sql不蛋疼吗?
请问如何写更好?
我错在哪?
select * from eload_goods where goods_sn like '(select left(goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1)%'
不知字符串吗
我理解你的意思,'select...' 是字符串,所以我是请教解决的写法嘛。