May 26, 2005 at 6:42 am
I'm trying to filter a selection by partial postcode.
Full postcode would be of the format AB12 34CD but I need to return all those where the postcode begins AB12
SELECT a.*
FROM order_details od INNER JOIN
orders o ON od.order_number = o.order_number INNER JOIN
addresses a ON od.address_number = a.address_number
WHERE (od.product = 'KIT') AND (o.cancellation_reason IS NULL) AND (LEFT(4, a.postcode) IN ('NN10', 'RH17'))
any suggestions?
May 26, 2005 at 6:49 am
Hi
To return all start with AB12
u can use like 'AB12%' or if u need only with space then like 'AB12 %'
May 26, 2005 at 7:06 am
Hi,
Have tried LIKE
However its throwing back an error "converting the varchar value 'NG19 8DK' to a column of data type int"
The column is varchar so why is it trying to convert it at all?
May 26, 2005 at 7:25 am
SELECT a.*
FROM order_details od
INNER JOIN orders o ON od.order_number = o.order_number
INNER JOIN addresses a ON od.address_number = a.address_number
WHERE od.product = 'KIT'
AND o.cancellation_reason IS NULL
AND (a.postcode LIKE 'NN10%'
OR a.postcode LIKE 'RH17%')
May 26, 2005 at 7:35 am
Chris
Many thanks - that's sorted it out. And like all great solutions blindingly simple when you stop and think about it!
May 26, 2005 at 8:31 am
No problem, glad it helped. Those solutions are often the hardest to find.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply