SELECT u.category, u.name, u.address1, u.postcode, min(u.id) as id
FROM ukinfo u, subcategory s where s.name = 'Inland Revenue' and u.category=s.name
and county = 'Norfolk'
and (town='King's Lynn' or address3extra='King's Lynn' or address2extra='King's Lynn')
group by category, name, address1, postcode
order by category, postcode
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Lynn' or address3extra='King's Lynn' or address2extra='King's Lynn')
group by ' at line 4
Error