Ask a simple sql:
SELECT * from Eload_goods where goods_sn like ' (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 1263 XX limit 1)% '
What's wrong with this SQL? No results found.
SELECT * from eload_goods where goods_sn = (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 l Imit 1)
There is a result in this search.
Note: The subquery is correct. The subquery returns the result: IE0384701
GOODS_SN is a varchar data type
Reply to discussion (solution)
What do you mean by adding a%?
Nothing wrong.
But I'm not going to believe it. (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1) ... Such a string
Nothing wrong.
But I'm not going to believe it. (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1) ... Such a string
Moderator, you are wrong.
(select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 126300 limit 1) is absolutely correct. There are also such strings.
The problem has been solved and the answer is attached:
SELECT * from Eload_goods where GOODS_SN like (SELECT CONCAT (goods_sn,9), '% ') as goods_sn from Eload_goods where good s_id = 126300 LIMIT 1)
Where was I wrong?
SELECT * from Eload_goods where goods_sn like ' (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 1263 XX limit 1)% '
Don't know the string?
SELECT * from Eload_goods where GOODS_SN like (SELECT CONCAT (goods_sn,9), '% ') as goods_sn from Eload_goods where good s_id = 126300 LIMIT 1)
Does this kind of SQL do not have the egg ache?
Where was I wrong?
SELECT * from Eload_goods where goods_sn like ' (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 1263 XX limit 1)% '
Don't know the string?
MySQL sub-query does not support limit, should be limit 1 caused by the error bar
If GOODS_ID is the primary key, limit 1 is completely unnecessary and is not supported
The reason for the error is that the single quotation marks, the contents of the single quotation mark are not searched, but the quotation mark content area is directly matched.
SELECT * from Eload_goods where GOODS_SN like (SELECT CONCAT (goods_sn,9), '% ') as goods_sn from Eload_goods where good s_id = 126300 LIMIT 1)
Does this kind of SQL do not have the egg ache?
How can I write better?
Where was I wrong?
SELECT * from Eload_goods where goods_sn like ' (select Left (goods_sn,9) as goods_sn from eload_goods where goods_id = 1263 XX limit 1)% '
Don't know the string?
I understand what you mean, ' Select ... ' is a string, so I am to ask for a solution to the wording.