Jump to content
Larry Ullman's Book Forums

17.4 - Pg 540 #3 (Non-Matching Queries Pages 540 + 541)


Recommended Posts

Hi,

 

The queries on the 2 pages aren't the same - the query on pg 541 is shown in example B and has run succesfully in the screen shot.  The query on the top of the previous page (540, #3) is different - I typed that into the terminal and ran it and received an error:

SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, 
MAX(DATE_FORMAT($last, '%e-%b-%y %1:$i %p')) AS last, MIN(DATE_FORMAT($first, 
'%e-%b-%y %1:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING 
(thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = 
{$_SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use 
near '['lid']} GROUP BY (p.thread_id) ORDER BY last DESC' at line 5



I noticed in the example B on page 541 there are many differences such as having CONVERT_TZ and setting t.lang_id = 4. 

 

Is this conflicting/wrong, or just a different example?

 

Why does the query I entered above have this error?

Link to comment
Share on other sites

 Share

×
×
  • Create New...