7
Answers

need a sql query

there are two tables
 1.UserInfo (columns Id,Mobileno)
2.Usertryinfo(columns Id,Mobileno)
 
i need a query 
userinfo has mobileno and id but
usertryinfo doesn't have mobileno respective id
 
(ids are same as userinfo)
 
Answers (7)
0
Rafnas T P

Rafnas T P

NA 12.2k 435.7k 8y
select ut.Userguid
,ui.MobileNo
from userTryInfo ut
left join userInfo ui on ui.Userguid= ut.Userguid
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
If you just say "its not a perfect query" how exactly we are suppose to be helping you?
 
As Suvendu mentioned, please give some sample data.
 
Now I don't know what is stored in MobileNo column in userTryInfo. You might have stored one space there (' '). If that is the case, the query given by me will definitely not work. But how will know what you have stored.
 
So, please help us help you!
 
0
aiswarjya sarengi

aiswarjya sarengi

NA 271 9.1k 8y
its not a perfect query
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
If mobileNo in userTryInfo is an empty string, then try following:
 
select ui.id
,ui.MobileNo
from userInfo ui
left outer join userTryInfo uti on ui.id = uti.id
where nullif(uti.MobileNo, '') is null
 
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
I hope I am getting it right. My interpretation is, get all records from userInfo table where there is no matching record in userTryInfo. Basically it's an unmatched query.
  
Try following: 
 
select ui.id
,ui.MobileNo
from userInfo ui
left outer join userTryInfo uti on ui.id = uti.id
where uti.MobileNo is null
0
aiswarjya sarengi

aiswarjya sarengi

NA 271 9.1k 8y
Usertryinfo :
 
Userguid Mobileno
EB8C3FC7-0BD1-435D-852D-F61643F65BB0  
03868C93-9121-42D0-B3FB-CEF972B69CEE  
 
 
in the table userinfo has the mobileno
 
 
i need all the mobilenos respective of ids from userinfo.
0
Suvendu Shekhar Giri

Suvendu Shekhar Giri

NA 7k 83.2k 8y
What is the desired result you need exactly?
Can you share 1-2 sample records which you want to see as result?