| |

VerySource

 Forgot password?
 Register
Search
View: 1043|Reply: 7

Find out the content of one field in the table contains another field, how to write ???

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-31 18:40:01
| Show all posts |Read mode
There are two tables A, B
Form A: (standard form)
nname, city, adress
Form B:
mname, sds,
The purpose I want to achieve is to find out that the mname field in table B contains the data of nname field of table A. Get table C:
mname, sds, nname, city, adress fields mname contains nname field
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-3-11 02:15:01
| Show all posts
--try
select * from A, B
where A.nname = B.mname
Reply

Use magic Report

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-3-11 09:15:01
| Show all posts
select *
from B _b
join A _a on _b.name like '%' + _a.name + '%'
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-3-11 10:00:01
| Show all posts
select mname, sds, name, city, address from A, B
where A.name = B.mname
Reply

Use magic Report

0

Threads

93

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 China

Post time: 2020-3-12 16:45:01
| Show all posts
select a.name, b.name from a, b where charindex (a.name, b.name)> 0--the name of table B contains A.name
Reply

Use magic Report

1

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-12 22:45:02
| Show all posts
select b.mname, b.sds, a.nname, a.city, a.adress
from a, b
where b.nname = a.mname
Reply

Use magic Report

0

Threads

22

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-3-13 13:30:02
| Show all posts
insert into c select * from an inner join b on b.name like a.name | '%';
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-19 17:00:01
| Show all posts
One more sentence, if 'ALAM INFORMASI TEKNOLOGI', I want to take the first two words, how to write it?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list