문제

I want to write a SELECT command that the Space character was not important.

for example

My data
-------
AB DE
A EFF
A E F E
ABC DEF

And my answer should be this:

AB DE
A EFF
A E F E

it means "I want all the 4length word that start with 'A' and the space character is not important".

How can I write this SELECT command???

도움이 되었습니까?

해결책

You can split the condition in two, one for starting with A and one for the length.
You can use REPLACE to remove the spaces and just check the length of the remaining characters.

SELECT * 
FROM mytable
WHERE mydata LIKE 'A%'
 AND LENGTH(REPLACE(mydata, ' ', '')) = 4;

An SQLfiddle to test with.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top