Wrestling with a syntax error

Hi all,

I’m wrestling a bit with a syntax error that I’m unable to figure out and am wondering if someone on this forum might be able to help me see the light.

Here’s the query and the resulting error:

mysql> SELECT u.name AS 'connect username', field_firstName.value AS 'first name', field_lastName.value AS 'last name', field_title.value AS 'job title', u.mail AS 'email address', field_shipping_address.value AS 'address', DATE_FORMAT(FROM_UNIXTIME(u.access),'%b-%d-%Y') AS 'last visit', n.title AS 'group'
    ->   FROM users u
    ->   LEFT JOIN profile_values as field_firstName ON u.uid = field_firstName.uid AND field_firstName.field_name = 'profile_firstName'
    ->   LEFT JOIN profile_values as field_lastName ON u.uid = field_lastName.uid AND field_lastName.field_name = 'profile_lastName'
    ->   LEFT JOIN profile_values as field_title ON u.uid = field_title.uid AND field_title.field_name = 'title'
    ->   LEFT JOIN profile_values as field_shipping_address ON u.uid = field_shipping_address.uid AND field_shipping_address.field_name = 'profile_shipping_address'
    ->   LEFT JOIN profile_values pv
    -> LEFT OUTER JOIN og_uid og
    ->   ON u.uid = og.uid
    -> LEFT OUTER JOIN node n
    ->   ON og.nid = n.nid
    -> WHERE n.nid = 3163
    -> ORDER BY n.title ASC, u.access 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 'WHERE n.nid = 3163
ORDER BY n.title ASC, u.access DESC' at line 12


the left join to pv is missing its ON clause

Thank you!