1 Replies - 699 Views - Last Post: 29 August 2012 - 03:03 AM

#1 notice88  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 21-December 11

Cant get results from table with 2 inner joins and where statement

Posted 29 August 2012 - 12:51 AM

Im getting everything if the query dont have where clause. But when it has, I dont get any..

In php, im making a search function in Notification2 table. Notification has the DocumentID(DocID) which must be inner join to Documents table. Documents has a colunm called PreparedBy. In PreparedBy column, it only consist the UserID of the user so Documents table must be inner join to Users table because Im searching for the FirstName combined with the last name of the UserId in PreparedBy. In Users table, to get the full name i must combine the FirstName and Last Name

Ive come up to this but does not give the the results i want. Refer to screen shots..


select
dbo.Notification2.id as NotificationsID,
dbo.Documents.PreparedBy as PreparedByID,
(Users.FirstName+' '+Users.LastName) as PreparedByName,
dbo.Notification2.DocID as NotificationDocumentID
FROM
(Notification2 inner join Documents on dbo.Notification2.DocID = dbo.Documents.DocID)
inner join dbo.Users ON dbo.Documents.PreparedBy = dbo.Users.UserID
where (Users.FirstName+' '+Users.LastName) like ''

Attached image(s)

  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Cant get results from table with 2 inner joins and where statement

#2 notice88  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 21-December 11

Re: Cant get results from table with 2 inner joins and where statement

Posted 29 August 2012 - 03:03 AM

I forgot to put %% in '' using like. so it will become '%%'....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1