Pregunta

I am trying to construct an ESQL query which should return an address entity after successfully matching its single address field by postcode and house number provided.

The house number is always at the start of the string but is sometimes prefixed with a zero ie.

042a Fake Street

I'd like to use trim() or ltrim() on the a.Address field but it doesn't seem to work for anything other than spaces?

This is a simplified version of my query :

select value a from MyEntities.tblAddresses as a where a.Address LIKE '42A %'

Any help would be much appreciated as always!

¿Fue útil?

Solución

I would not convert the value of a database column before using it in a filter unless everything else fails. The reason is that the conversion prevents any indexes to be used in the search (it is not sargable). But, anyway, there is no canonical function by which you could easily do this kind of Trim.

I think the most straightforward way is to search by LIKE '42A %' OR LIKE '042A %'.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top