0

How do I get all the rows of a table that have one word, and the ones that have more then a word:

For example take the following records:

CARROCARIA PINTURA
VEICULOS ALUGUER
VEICULOS ELETRICOS
SERVICOS RAPIDOS
VEICULOS COMERCIAIS
ELETRICIDADE
VIDROS

I get with query 1:

ELETRICIDADE
VIDROS

I get with Query 2:

CARROCARIA PINTURA
VEICULOS ALUGUER
VEICULOS ELETRICOS
SERVICOS RAPIDOS
VEICULOS COMERCIAIS

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Patrick
  • 2,995
  • 14
  • 64
  • 125

1 Answers1

5

One word

select * from tablename where fieldname not like '% %'

multiple words

select * from tablename where fieldname like '% %'

EDIT

if leading / trailing spaces could be an issue, you can use something like

select * from tablename where ltrim(rtrim(fieldname)) like '% %'
Ian Kenney
  • 6,376
  • 1
  • 25
  • 44