-
name,cityid,areacode,phone
from customer where instr(name,'Zhang') = 1
count(*)from customer where instr(name,'Zhang') =1
count(*)from customer where instr(name,'Zhang') = 1 and cityid = (select cityid from city where cityname = 'Shanghai')
This is to make a Cartesian product of the two tables, and connect the two tables according to the cityid.
select count(*)from customer t1,city t2 where instr(,'Zhang') = 1 and = 'Shanghai' and =
It can also be so bloody.
select count(*)from customer t1 left join city t2
on =where instr(,'Zhang') = 1 and = 'Shanghai'
select , from (
select cityid,count(*)ct from customer where instr(name,'Zhang') = 1
group by cityid
t,city t1
where =
Theoretically, count(1) and count(*) have almost the same performance, so don't be fooled.
If the amount of data is large, it is not recommended to use like, because when you use like, you do not need an index and scan it progressively.
ps: Upstairs is what you said count(1) performance is higher than count(*).
-
1. Inner join
select * from a inner join b on ;
The result of this statement is a recordset that matches both Table A and Table B. That is, the inner join takes the intersection of two tables.
2. Full outer join
select * from a full outer join b on ;
The result of this statement is the union of table A and table b, that is, the contents of any table will be queried, and if the other table has no corresponding items, it will be displayed as null
select * from a full outer join b on where is null or is null;
The result of this statement is the union of tables A and B minus the intersection of the two tables. That is, the parts that are present in both tables are removed, and the parts that are left are different from each other.
3. Left Outer Join
select * from a left outer join b on ;
The result of this statement is that all items in Table A are added to the items in Table B that match A, and the items in Table B are displayed as null if there are no items in Table B that match A
select * from a left outer join b on where is null;
The result of this statement is all entries in Table A minus the intersection of the two tables.
4. Right outer join
select * from a right outer join b on ;
The result of this statement is the items in Table A that match Table B plus all the items in Table B, and the items in Table A are null if there are no items in Table B
select * from a right outer join b on where is null;
The result of this statement is all of Table B minus the intersection of the two tables.
What's wrong with the long distance?! Long-distance love can come together to make envy! As long as you are sincere, the distance is even more precious! >>>More
Complaining won't solve anything, so it's better to sort out your mood and start again. Be an honest person, don't tell lies, do more practical things, and treat people with sincerity. Be a self-aware person, don't talk big, don't brag, and be a down-to-earth person. >>>More
Dream about monkeys sleeping : going on a trip to a foreign country. Dream About Monkeys Eating : >>>More
In the middle school context, there is no solution to this problem, which is determined by the nature of odd and even numbers. Because the numbers given in this problem are all odd numbers, and the sum of three odd numbers is still an odd number, and it is impossible to get an even number of 30, so there is no solution to this problem. >>>More