开发者

How to only add values that end with 's'?

I'd like to do this but I know this isn't the right syntax:

INSERT INTO TBL1
SELECT开发者_开发技巧 Col1    
FROM TBL2    
WHERE Col1.endswith('s')


INSERT INTO TBL1
SELECT Col1    
FROM TBL2    
WHERE col1 LIKE '%s'

where % works like * in wildcard and .* in RegEx. It is SQL Server RegEx pattern indeed.


INSERT INTO TBL1 
SELECT Col1
FROM TBL2
WHERE Col1 LIKE '%s'


Insert Into TBL1
select Col1
from TBL2
where Col1 like '%s'


WHERE col1 like '%s'

% is the wildcard character which takes any value or any number of characters.

This site is good for learning this kind of thing: http://www.w3schools.com/sql/sql_like.asp


Here is a correction to the where clause of your insert statement:

where substring(col1,LEN(col1)-1,1) = 's'

Here is your complete insert statement with the corrected where clause:

INSERT INTO TBL1
SELECT Col1    
FROM TBL2    
WHERE where substring(col1,LEN(col1)-1,1) = 's'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜