Home  >  Article  >  Backend Development  >  javascript - issues with not in, in and Null

javascript - issues with not in, in and Null

WBOY
WBOYOriginal
2016-08-04 09:21:143661browse

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.

Reply content:

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

  1. 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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn