Here is my table structure:
Table: User
Fields: UserId,FirstName,LastName,FriendCount
Table: Network_User
Fields: UserId,NetworkId
Table: Network
Fields: NetworkId, Network
Table: Keyword_User
Fields: UserId,KeywordId
Table: Keyword
Fields: KeywordId, Keyword
This query works correctly:
This one does not:
I know the correct data is in the tables for it to return.
I noticed that
While
Any idea why?
Table: User
Fields: UserId,FirstName,LastName,FriendCount
Table: Network_User
Fields: UserId,NetworkId
Table: Network
Fields: NetworkId, Network
Table: Keyword_User
Fields: UserId,KeywordId
Table: Keyword
Fields: KeywordId, Keyword
This query works correctly:
It returns 2 rows.SELECT u.UserId,u.FirstName,u.LastName,u.FriendCount FROM `User` u
LEFT JOIN `Network_User` nu ON nu.UserId = u.UserId
LEFT JOIN `Network` n ON nu.NetworkId = n.NetworkId
WHERE n.Network = 'Purdue' ORDER BY u.FriendCount DESC
This one does not:
It returns an empty set, where it should return 2 rows like the other one.SELECT u.UserId,u.FirstName,u.LastName,u.FriendCount FROM `User` u
LEFT JOIN `Keyword_User` ku ON ku.UserId = u.UserId
LEFT JOIN `Keyword` k ON ku.KeywordId = k.KeywordId
WHERE k.Keyword = 'weeds' ORDER BY u.FriendCount DESC
I know the correct data is in the tables for it to return.
I noticed that
Also fails.SELECT * FROM `Keyword` WHERE `Keyword` = 'weeds'
While
Works fineSELECT * FROM `Network` WHERE `Network` = 'Purdue'
Any idea why?