Home > database >  How about two table join SQL to form new watch
How about two table join SQL to form new watch

Time:10-06


I have A table format below
| id value | |
| 1 | | A
| 2 | A |
| 3 | A |

Table B
Id value | |
| | | 5 B
6 | | | B
| | B |
| | B | 1

Table A and B connection how to write A SQL to form the following table structure
Id value
1 A
2 A
3 A
4 B
5 B
6 B

CodePudding user response:

Select * from a
The union
Select * from b

CodePudding user response:

Select * from a
The union
Select * from b

I can't
- + -- -- -- -- -- -- -- +
| id value | |
+ - + -- -- -- -- -- -- -- +
| 1 | | A
| | B |
| 2 | A |
6 | | | B
| | B | 1
| | | 5 B
| 3 | A | id 1, there are two

CodePudding user response:

Select * from a
The union
Select * from b where id not in (select id from a)

CodePudding user response:

Junction post rate: 0%

reference
after your questions answered please post.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8, how to give points and knot stick?
http://bbs.csdn.net/help#post_dispose

CodePudding user response:

Select
*
The from (
Select * from a
The union
Select * from b where id not in (select id from a)
Aa)
The order by id asc
  • Related