Edith
Edith

Reputation: 23

WHERE column contains single word

How can I use SQL like to only display single words that are in a particular column of any row? For example, suppose I have the following rows in column1.

Column1

put return
need return
got return
bring return
server
client

The single-words output I would like is:

server
client

Can this be accomplish using like? I know this can be accomplished using regular expressions, but if possible, I would prefer using LIKE.

Upvotes: 2

Views: 92

Answers (2)

sagi
sagi

Reputation: 40481

SELECT * FROM YourTable
WHERE Column1 NOT LIKE '% %'

Or:

WHERE LOCATE(' ',Column1) = 0 

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270463

You can use not like:

where col not like '% %'

Upvotes: 4

Related Questions