Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems this your latest query attempt:</p> <pre><code>SELECT a1.*, p.lifeSpan, a2.* FROM Zoo AS z INNER JOIN Plants AS p ON p.parent_id=z.id INNER JOIN Animal AS a1 ON (a1.id=z.predator) INNER JOIN Animal AS a2 ON (a2.id=z.prey)"; WHERE z.preyType=@carnivore </code></pre> <p>Discard the semicolon from inside the statement. Also discard the double quote. </p> <p>Just to simplify the SQL, exclude the WHERE clause for now. </p> <p>Then you should be in a better position to address the issue of parentheses which Access' db engine requires for multiple joins.</p> <pre><code>SELECT a1.*, p.lifeSpan, a2.* FROM ((Zoo AS z INNER JOIN Plants AS p ON p.parent_id=z.id) INNER JOIN Animal AS a1 ON a1.id=z.predator) INNER JOIN Animal AS a2 ON a2.id=z.prey </code></pre> <p>Notice I discarded those parentheses which enclosed the ON expressions. Simple ON expressions don't require them. If you had a compound expression for ON, then you would need parentheses like this:</p> <pre><code>ON (p.parent_id=z.id AND p.foo = z.bar) </code></pre> <p>The sample query I suggested looks correct to me. (If it works for you, add your WHERE clause back again.) However, I don't pay close attention to parentheses placement because I use Access' query designer to set up joins ... and it adds the parentheses the db engine requires. </p> <p>I urge you to do the same. If you're using an Access db from Dot.Net without having a copy of Access installed, you really should get a copy. Trying to use a database without that database's native development tools is an unreasonable challenge ... somewhat like trying to type while wearing mittens. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload