SELECT with a Replace()

前端 未结 8 1022
执念已碎
执念已碎 2021-01-31 09:03

I have a table of names and addresses, which includes a postcode column. I want to strip the spaces from the postcodes and select any that match a particular pattern. I\'m tryin

8条回答
  •  粉色の甜心
    2021-01-31 09:31

    You are creating an alias P and later in the where clause you are using the same, that is what is creating the problem. Don't use P in where, try this instead:

    SELECT Replace(Postcode, ' ', '') AS P FROM Contacts
    WHERE Postcode LIKE 'NW101%'
    

提交回复
热议问题