I have a table
custd
name email no
kuldeep kldthakur@gmail.com 99
and second table
pkd
list weight type address name
p1 100 formal delhi kuldeep
Now I want to search the detail by name from the database and the detail should be come from the both table like :-
name email no list weight type address
kuldeep kldthakur@gmail.com 99 p1 100 formal delhi
Please tell the how I can solve this prob. with which query I'm using sql server.
Well, you just need a join. It looks like you have a foreign key on name
, so this should work:
select * from custd c
join pkd p on c.name = p.name
This should do:
select pkd.name
,custd.email
,custd.no
,pkd.list
,pkd.weight
,pkd.type
,pkd.address
from custd join pkd on pkd.name=custd.name
But we aware that if name is not a unique key, you can get lots of incorrect results.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.