I tried to Google this and to search the forums here but could not find what I need. Basically there are several instances where I am pulling data from two tables together. In one case I have entries with a UserID field and I am pulling the Username from another table linked on this field. The problem I have is when no corresponding entry exists in the second table, the record does not show up at all.
Sample tables and data, SQL, and records returned are below:
UserPosts:
P_ID, P_UserID, P_Comment
1, 1, 'Test 1'
2, 2, 'Test 2'
3, 7, 'Test 3'
Users:
U_ID, U_Username
1, 'Test User 1'
2, 'Test User 2'
3, 'Test User 3'
10, 'Test User 10'
SQL: SELECT P_ID, P_UserID, P_Comment, U_Username FROM UserPosts, Users WHERE (UserPosts.P_UserID = Users.U_ID)
Returns:
1, 1, 'Test 1', 'Test User 1'
2, 2, 'Test 2', 'Test User 2'
How can I solve this problem? Do I just require that the data not be deleted so that related queries function properly?
Thanks,








.

Bookmarks