Thursday, July 1, 2010

sql innerjoin,max and sub qyery

select A1.Name,A1.AccountNumber,B1.MessageText,B1.MessageID from Customers a1 inner join SMSRecieved b1 on B1.PhoneNo=A1.MobileNumber where B1.PhoneNo ='" + txtMobileNumber.Text + "' and b1.ReceivedTime =(select max(ReceivedTime) from SMSRecieved where PhoneNo='" + txtMobileNumber.Text + "')

No comments:

Post a Comment