What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

When I run the following not all the records diplay a value in the Title field:

SELECT
    Users.DisplayName,
    Posts.OwnerDisplayName,
    Posts.Title,
    Posts.Score
FROM 
    Posts 
    INNER JOIN Users ON Posts.OwnerUserId = Users.id    
WHERE 
    Users.DisplayName = 'whytheq'
ORDER BY 4 desc

Why is this?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Some of your posts are answers, which don't have the title field populated.

You can left join back to Posts on ParentId and then coalesce the title field if you want the title displayed in all cases, or select Posts.Id AS [Post Link], which will give you the title as a link to the post in question.

Also note that usernames are not unique, so generally you'd want to select using your user ID as input, which Data Explorer will attempt to guess for you automatically based on your email hash if you're a registered user and you do something like WHERE Posts.OwnerUserId == ##UserId##.

share|improve this answer
1  
Or add and Posts.PostTypeId = 1 to the WHERE clause to get just questions... –  ben is uǝq backwards Dec 28 '12 at 14:10
    
I was going to also ask "If I run the following why is Users.DisplayName populated in the result set whereas Posts.OwnerDisplayName is blank ?" ...._the following_ being the same query as this questions OP. I've not got enough rep points to ask another question so soon. –  whytheq Dec 28 '12 at 14:12
    
@benisuǝqbackwards - upped comment just for having the best user name I've seen. –  whytheq Dec 28 '12 at 14:13
    
@whytheq Posts.OwnerDispalyName is only populated in cases where the display name has been denormalized, such as in an account deletion or a community wiki post. –  Tim Stone Dec 28 '12 at 14:13
    
@TimStone - ok so not a field I need to worry about. Hey - is there a page with definitions of all the fields? –  whytheq Dec 28 '12 at 14:17
    
@whytheq There's this slightly outdated schema overview, but I'll make a note that something a bit more comprehensive might be helpful. –  Tim Stone Dec 28 '12 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .