MySQL 5.5.54
I have two tables, both with the same structure. I want to select records from table 1 based on the values in table 2.
I have a field, thevalue, which contains values such as:
181-1-0001
181-1-0002
181-2-0001
181-2-0004
I have the query:
SELECT * FROM table1 where thevalue in(SELECT distinct concat('Like ''',left(rangeid,8),'%''') FROM table2)
when I run this query I don't get an error but 0 rows are returned. when I run the inner select statement separately it returns
'Like \'181-1-00%\''
'Like \'182-1-00%\''
'Like \'183-2-00%\''
'Like \'187-2-00%\''
'Like \'188-2-00%\''
Can anyone suggest how I can return the rows in table1 where the first 8 characters of the thevalue field match those in the thevalue field of table2?
Our community of experts have been thoroughly vetted for their expertise and industry experience.
This award recognizes a member of Experts Exchange who has made outstanding contributions to the community within their first year as an expert. The Rookie of the Year is awarded to a new expert who has the highest number of quality contributions.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.