Home >Backend Development >PHP Tutorial >javascript - issues with not in, in and Null
1. There are two arrays
(1), array(1,2);
(2), array(1);
(1)(2). The values of these two arrays are not fixed and can only be used through foreach Combining in_array() to get disjoint sets?
2. What is the difference in execution efficiency between using not in, in and Null in SQL? It would be best to give an example to illustrate.
Null cannot use index, resulting in low efficiency? So how should I solve this problem? My database field is Null by default.
1. There are two arrays
(1), array(1,2);
(2), array(1);
(1)(2). The values of these two arrays are not fixed and can only be used through foreach Combining in_array() to get disjoint sets?
2. What is the difference in execution efficiency between using not in, in and Null in SQL? It would be best to give an example to illustrate.
Null cannot use index, resulting in low efficiency? So how should I solve this problem? My database field is Null by default.
1. Use a loop inside a loop to compare the elements in each array. If they are the same, delete the same element from both arrays.
The last thing left in the two arrays is the difference set.
2. Change the default value to "" and that's it.
array_diff() This function can get the difference set of arrays. You can try it
<code>a.filter(key => !b.includes(key))</code>
You can get the difference between arrays a and b like this
array_diff([1],[1,2]) can get the value group that you don’t want to hand over
2. Change the default value to "", it is best to set the database field to not null