Jump to content
Larry Ullman's Book Forums

ti8er

Members
  • Posts

    2
  • Joined

  • Last visited

ti8er's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I totally understand the answer now...but unfortunately cant edit the post. I think the confusion was because the IF(COUNT...) line in the middle. "username" is in the "users" table so "SELECT u.username.........FROM users AS u" makes sense. Hopefully that's the correct understanding. Thanks
  2. Hi, Apologies in advance if the answer to this question is very obvious. I've tried googling but haven't found a satisfactory answer. From page 220 of the Kindle version of your text book. Question 4: "For each user, find the number of messages they’ve posted, converting zeros to the string None" The answer is: SELECT u.username, IF(COUNT(message_id) > 0, COUNT(message_id), 'None') AS Posts FROM users AS u LEFT JOIN messages AS m USING (user_id) GROUP BY (u.user_id); Shouldn’t line three be “FROM messages AS m”? (and then instead of "LEFT JOIN messages as m" you "LEFT JOIN users AS u") Since the “message_id” (used for the counting part on the previous line) is “FROM" the messages table and not from the users table? It's just a nagging question I had at the back of my mind cause it seems counter intuitive to the English meaning of the word "from". So I tried googling the MYSQL defintion of "FROM" to see if it means something different but couldnt find anything... Many thanks for your assistance, p.s. Your book has been very helpful.
×
×
  • Create New...