Class Registrations

WordPress database error: [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 'AND STS_ID = 'RAP'' at line 16]
SELECT smkc.wp_esp_registration.REG_ID, EVT_ID, STS_ID, REG_date, ATT_fname, ATT_lname, ATT_email, ATT_phone, post_title, DogName, DogAge, DogBreed FROM smkc.wp_esp_registration inner join smkc.wp_esp_attendee_meta on smkc.wp_esp_registration.att_id = smkc.wp_esp_attendee_meta.ATT_ID INNER JOIN smkc.wp_posts ON smkc.wp_esp_registration.EVT_ID = smkc.wp_posts.ID INNER JOIN (SELECT REG_ID, QST_ID, ANS_value as DogName FROM smkc.wp_esp_answer) as NameTable ON NameTable.REG_ID = smkc.wp_esp_registration.REG_ID AND NameTable.QST_ID = 21 INNER JOIN (SELECT REG_ID, QST_ID, ANS_value as DogAge FROM smkc.wp_esp_answer) as AgeTable ON AgeTable.REG_ID = smkc.wp_esp_registration.REG_ID AND AgeTable.QST_ID = 22 INNER JOIN (SELECT REG_ID, QST_ID, ANS_value as DogBreed FROM smkc.wp_esp_answer) as BreedTable ON BreedTable.REG_ID = smkc.wp_esp_registration.REG_ID AND BreedTable.QST_ID = 23 where smkc.wp_esp_registration.EVT_ID= AND STS_ID = 'RAP'

Student Name Email Phone Dog Name Dog Age Dog Breed