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
  • 704,970
  • 168
  • 1,303
  • 1,425
Patrick
  • 3,661
  • 12
  • 57
  • 117

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,166
  • 1
  • 24
  • 42