i have an issue on the below
table1
first case :
postcode
LS1 1LS
second case:
postcode
LS11LS
table2
postcode| region
LS1 | Leeds
LS11 | Leeds
and i am using the below query to count the region versus related postcode
SELECT table2.region as 'Region', COUNT( table2.postcode ) as 'count'
FROM table1
INNER JOIN table2 ON table1.postcode LIKE CONCAT( table2.postcode, '%' )
WHERE table1.postcode > ''
GROUP BY Region
on applying that on table 1 first case i get
Leeds | 1
on applying it on table 1 second case i get
Leeds | 2
for some reason on this postcode / similar postcodes where the other half is exactly like the first part and there is no spaces in between the like inner join returns the count as 2.
any solution for this ?
see this sqlfiddle