0

I'm currently working with 3 tables: tblOwner, tblAnimal, tblVisit. I want to join the three of them based on ownerid (which connects tblOwner and tblAnimal) and animalid (which connects tblAnimal and tblVisit). What I'm trying to do exactly is create a query (in MS Access) that only shows firstname, lastname, city, state (from tblOwner), as well as the reason/diagnosis (from tblVisit) only for animals that are injured. I have to use tblAnimal due to animalid, which allows me to indirectly connect tblOwner to tblVisit. I've found multiple ways to inner join 3 tables but none seem to work. Thank you in advance

When I try to run the code, I get the following error: syntax error (missing operator) in query expression "o.ownerid = a.ownerid INNER JOIN tblVisit AS v ON v.animalid = a.animali"

SELECT o.firstname, o.lastname, o.city, o.state, a.animalname, v.reason/diagnosis, v.animalid

FROM tblOwner as o

INNER JOIN tblAnimal AS a ON o.ownerid = a.ownerid

INNER JOIN tblVisit AS v ON v.animalid = a.animalid

WHERE v.reason/diagnosis LIKE "%Injured%"

ORDER BY o.firstname;
Arthur
  • 51
  • 4
  • In addition to the parentheses you will also need to do `v.[reason/diagnosis]`. – Andre Mar 27 '23 at 23:32
  • 1
    `reason/diagnosis` is a horrible, horrible field name. – RobIII Mar 27 '23 at 23:34
  • Advise not to use space nor punctuation/special characters (underscore only exception) in naming convention. Access is picky about parentheses in JOIN ON clause. Use the query designer to get correct syntax. – June7 Mar 28 '23 at 01:50

0 Answers0