1. SQL questions
Purpose: Query the account opening status of each bank of all users (for example, a bank has multiple accounts, only one can be listed)
答案:SELECT *from `user` GROUP BY username,bank1
The core is that GROUP BY can be followed by multiple fields . The order of the fields does not affect the results, and the results are the same. According to group by a, b, they are grouped according to a and b at the same time.
Group by generally only makes sense to use it with aggregate functions, such as count sum avg, etc., using two elements of group by:
(1) The fields that appear after select are either in aggregate functions or in group by.
(2) To filter the results, you can use where and then group by or group by and then having
2. js questions
var x = 1; function test(){ alert(x); var x="hello word"; alert(x); } test();
popup content twice?
The answer pops up as undefined for the first time, helloword for the second time
think:
var x = 1; function test(){ alert(x); x="hello word"; //Cancel var alert(x); } test();
The answer pops up as 1 the first time and helloword the second time
Reason: 1. The scope of var js initialization variable plus var is a global variable when it is not added. In fact, in the first program, the x outside the function and the x inside the function are not the same x. In fact, in the second program, the x outside the function and the x inside the function are actually the same x (global variable).
2. The difference between var and let When using an undeclared variable, var is undefined, and let reports an error directly