Hi.
In one of my tables I have two columns labelled postcodes and noncover. Both are text fields and contain data such as:
postcodes column:
CF*,NP1,NP2,NP3,NP9
noncover column:
CF31,CF32,CF33,CF34,CF35,CF36
I am trying to run the following statement to select a record which has the postcode within the postcodes column. Also, if the postcode is in the noncover column then I don't want the record to be returned.
Here's the SQL:
SELECT FROM franchise_holders
WHERE (postcodes LIKE 'CF35%' OR postcodes LIKE '%,CF35%' OR postcodes LIKE 'CF%' OR postcodes LIKE '%,CF*%')
AND (noncover NOT LIKE 'CF35%' OR noncover NOT LIKE '%,CF35%')
However, this SQL is returning rows that have the postcode in both the postcodes and noncover columns.
Can anyone point out to me what I'm doing wrong?
Many thanks in advance guys.