string-concatenation

Handling NULL in Sql server string concatenation

≯℡__Kan透↙ 提交于 2020-06-27 13:58:37
问题 I have the following SQL query select s.comments + s.further_comments from dbo.samples s where id = 1234 However if s.comments or s.further_comments is NULL the whole string is returned NULL How do I convert the NULL value to an empty string or at least only return the non NULL values in this string? 回答1: You can use either ISNULL or COALESCE for this. SELECT ISNULL(s.comments, '') + ISNULL(s.further_comments, '') SELECT COALESCE(s.comments, '') + COALESCE(s.further_comments, '') ISNULL

Handling NULL in Sql server string concatenation

蓝咒 提交于 2020-06-27 13:58:25
问题 I have the following SQL query select s.comments + s.further_comments from dbo.samples s where id = 1234 However if s.comments or s.further_comments is NULL the whole string is returned NULL How do I convert the NULL value to an empty string or at least only return the non NULL values in this string? 回答1: You can use either ISNULL or COALESCE for this. SELECT ISNULL(s.comments, '') + ISNULL(s.further_comments, '') SELECT COALESCE(s.comments, '') + COALESCE(s.further_comments, '') ISNULL

Replace a string in a macro variable?

雨燕双飞 提交于 2020-06-26 13:51:26
问题 I have a macro where I pass in an argument and use that define a new variable based on the name of the input: #define DO_X(x) char _do_x_var_ ## x; /* other things */ The problem is if I pass in a struct variable, it breaks: DO_X(some_struct->thing) becomes: char _do_x_var_some_struct->thing; /* other things */ EDIT: What I want it to evaluate to is: char _do_x_var_some_struct__thing; /* other things */ (or any valid variable name containing something similar to the input) What I actually

Can I use require(“path”).join to safely concatenate urls?

Deadly 提交于 2020-06-24 01:44:33
问题 Is this safe to use require("path").join to concatenate URLs, for example: require("path").join("http://example.com", "ok"); //returns 'http://example.com/ok' require("path").join("http://example.com/", "ok"); //returns 'http://example.com/ok' If not, what way would you suggest for doing this without writing code full of ifs? 回答1: No. path.join() will return incorrect values when used with URLs. It sounds like you want url.resolve . From the Node docs: url.resolve('/one/two/three', 'four') //

Can I use require(“path”).join to safely concatenate urls?

泄露秘密 提交于 2020-06-24 01:44:22
问题 Is this safe to use require("path").join to concatenate URLs, for example: require("path").join("http://example.com", "ok"); //returns 'http://example.com/ok' require("path").join("http://example.com/", "ok"); //returns 'http://example.com/ok' If not, what way would you suggest for doing this without writing code full of ifs? 回答1: No. path.join() will return incorrect values when used with URLs. It sounds like you want url.resolve . From the Node docs: url.resolve('/one/two/three', 'four') //

Referencing firebase database with a variable and string concatenation

穿精又带淫゛_ 提交于 2020-06-17 00:13:08
问题 As you can see below i'm trying to read a list of data from the database and then loop over the result, in javascript. The function runs whenever i open/refresh the page: firebase.database().ref("Users/" + uid + "/rooms").on("value", function(snapshot) { snapshot.forEach(function(e) { var element = e.val(); var roomId = element.Id; }); }); However, that string concatenation to specify the User Id doesn't work for some reason. When i replace it with the user Id directly like this: firebase

How to list all posible ways to concatenate a list of strings

二次信任 提交于 2020-06-08 14:06:51
问题 I want to list all possible ways to concatenate a list of strings, example: Input: strings = ['hat','bag','cab'] Output: concatenated = ['hatbag','hatcab','hatbagcab','hatcabbag','baghat','bagcab', 'baghatcab','bagcabhat','cabhat','cabbag','cabhatbag','cabbaghat'] I've tried using for loops for this simple 3 string list, but I can't figure out how to do it with many strings in the list. Can someone please help? 回答1: This is a great case for the itertools module. You're looking for

shell: strange string concatenation behavior [duplicate]

旧巷老猫 提交于 2020-05-09 10:43:11
问题 This question already has answers here : Remove carriage return in Unix (19 answers) Closed 3 years ago . I write a scipt like this: #!/bin/bash while read line do echo line ${line} pdbfile=${line}.pdb echo pdbfile ${pdbfile} done < myfile The result is: line pdb8mhtA .pdbfile pdb8mhtA While it is supposed to be line pdb8mhtA pdbfile pdb8mhtA.pdb What's wrong with this? Why the string concatenation does not work? And why the strange dot at the beginning of the line? I replace with pdbfile=$

Arduino: Crashes and errors when concatenating Strings

邮差的信 提交于 2020-02-23 10:09:43
问题 I try to concatenate the output of AES-256 encryption to a string (to compare this string against the encrypted String sent from an Android phone). Basically, the concatination seems to work, but after a few runs errors (non readable characters, string getting shorter instead of longer) or crashes occur. It is reproducible, crashes at the exact same point after restart. I extracted some lines of Arduino code that demonstrate the problem. It does the following: Create a random number and write

Difference between String interpolation and String concatenation

孤者浪人 提交于 2020-02-20 06:10:27
问题 When specifically dealing with non-optional String values, what could be the difference between String interpolation and String concatenation? struct MyModel { let value1: String let value2: String var displayNameByConcatenation: String { return value1 + "-" + value2 } var displayNameByInterpolation: String { return "\(value1)-\(value2)" } } Is there going to be any case where displayNameByConcatenation and displayNameByInterpolation are different? Like on long unicode strings? Is it possible