开发者

String handling in T sql for mysql

开发者 https://www.devze.com 2023-01-08 17:13 出处:网络
I have a variable DECLARE url varchar(3000) and incoming开发者_开发技巧 parameters scheme VARCHAR(5),

I have a variable

DECLARE url varchar(3000)

and incoming开发者_开发技巧 parameters

scheme VARCHAR(5),
subdomain VARCHAR(55),
domain VARCHAR(55),
tld VARCHAR(55)

yet when i do the following:

SET url = url + ltrim(rtrim(scheme)) + '://';
SET url = url + ltrim(rtrim(subdomain)) + '.';
SET url = url + ltrim(rtrim(domain));
SET url = url+ '.' + ltrim(rtrim(tld));

And insert to the database i get "0"

I'm a newb with sql, what am i doing wrong?


Your initial url variable is NULL. Think of NULL like you would an undefined value in math — when you perform any operations on an undefined value, the result is still undefined. Similarly, if you concatenate NULL with a string, the result is still NULL (depending on the options set on the server/database/script). Set it to an empty string to start with and it should work.

0

精彩评论

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

关注公众号