title: MySQL - Nested where conditions
body: <p>I have a mysql table, which is as follows:</p>
  
  <pre><code> image_id   imagename   brandname    x       y    
      143     00003.jpg     Pirelli  147      265
      125     00003.jpg     Pirelli  500      259
  </code></pre>
  
  <p>Through mouse clicks I am generating x and y positions on a html canvas which I want to use to subset the table.  For example, if the clicked position of x and y were 510 and 262, I want to retrieve the image id 125 as both the parameters are matching.</p>
  
  <p>Suppose if the x value generated with mouse click is 510, i want to select the line with image_id 125.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>select * from table where imagename='00003.jpg' and 510 &lt; max(x);
  </code></pre>
  
  <p>I am getting this error: </p>
  
  <blockquote>
    <p>invalid use of group function.</p>
  </blockquote>