This returns 1 record from my table t1 as expected:
For the sake of discussion, let's say that the 1 "myfield" value returned was 123456. So then using that information, this will return multiple records like 123456, 123456A, 123456B, and so on and also works as expected:
So, putting those together, what I actually want is multiple records to be returned from this:
However, I only get the 1 record for 123456. My brain seems to be a bit frazzled a the moment and I can't decide if it's a logic problem in this query or a format problem. It seems like it should work, but I must be missing something.
Code:
SELECT DISTINCT myfield FROM t1
WHERE item = 'myitem'
LIMIT 1
;
For the sake of discussion, let's say that the 1 "myfield" value returned was 123456. So then using that information, this will return multiple records like 123456, 123456A, 123456B, and so on and also works as expected:
Code:
SELECT * FROM t1
WHERE myfield LIKE (CONCAT('123456','%'))
;
So, putting those together, what I actually want is multiple records to be returned from this:
Code:
SELECT * FROM t1
WHERE myfield LIKE (CONCAT(SELECT DISTINCT myfield FROM t1
WHERE item = 'myitem'
LIMIT 1),'%'))
;
However, I only get the 1 record for 123456. My brain seems to be a bit frazzled a the moment and I can't decide if it's a logic problem in this query or a format problem. It seems like it should work, but I must be missing something.