How to use select statement in a delete statement using MSSQL

To use select statement in a delete statement using MSSQL you can use the snippet below.

Sample MSSQL

DELETE TableOne
FROM   TableOne
       INNER JOIN TableTwo
               ON TableTwo.Id= TableOne.Id
                  AND ...
                       WHERE ...

Please rate this snippet

How to use a select in update statement using MSSQL

To use a select statement in a update statement using MSSQL you can use the snippet below.

Sample SQL

UPDATE TableOne
SET
    t1.ColumnOne = t2.ColumnOne,
    t1.ColumnTwo = t2.ColumnTwo
FROM
    TableOne AS t1
INNER JOIN
    TableTwo AS t2
ON
    TableOne.id = TableTwo.id

Please rate this snippet

How to join two lists in C# and VB.NET

To join two lists in C# and VB.NET you can use one of the following snippet.

Samples C#

//INIT
var listOne = new List<int>() { 1, 2, 3, 4, 5 };
var listTwo = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

//using Concat, this does not modify listOne. listThree includes all values, even the duplicates.
var listThree = listOne.Concat(listTwo).ToList();

//using Union, this does not modify listOne. listFour includes all values, without duplicates.
var listFour = listOne.Union(listTwo).ToList();

//using AddRange, this modifies listOne. listOne includes all values, even the duplicates.
listOne.AddRange(listTwo);

Samples VB.NET

'INIT
Dim listOne = New List(Of Integer)() From { 1, 2, 3, 4, 5 }
Dim listTwo = New List(Of Integer)() From { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

'using Concat, this does not modify listOne. listThree includes all values, even the duplicates.
Dim listThree = listOne.Concat(listTwo).ToList()

'using Union, this does not modify listOne. listFour includes all values, without duplicates.
Dim listFour = listOne.Union(listTwo).ToList()

'using AddRange, this modifies listOne. listOne includes all values, even the duplicates.
listOne.AddRange(listTwo)

Please rate this snippet

How to join the elements of a array to a string in JavaScript

To join the elements of a array to a string in JavaScript you can use the following snippet.

Sample Javascript

var days = ["Monday", "Tuesday", "Friday"];
var joinedDays = days.join(" and ");

Result

Monday and Tuesday and Friday

for more informations take a look at W3Schools JavaScript Array join() Method

Please rate this snippet