Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Run this query:</p> <pre><code>SELECT main.zc_zip, main.disabled, (ACOS( SIN(RADIANS(main.zc_lat)) * SIN(RADIANS(geo.zc_lat)) + COS(RADIANS(main.zc_lat)) * COS(RADIANS(geo.zc_lat)) * COS(RADIANS(main.zc_lon) - RADIANS(geo.zc_lon)) ) * 6380) AS `distance` FROM tx_sdfilmbase_geodb main LEFT JOIN tx_sdfilmbase_geodb geo ON geo.zc_location_name LIKE '%frauenfeld%' WHERE main.zc_zip in(8500, 8501, 8502, 8503) ORDER BY `distance` ASC </code></pre> <p>And then evaluate the results of <code>distance</code> and <code>disabled</code>. Your value of your function or disabled probably isn't what you're expecting it to be.</p> <p><strong>EDIT</strong> (In response to null result for distance field)</p> <pre><code>SELECT main.zc_zip, main.disabled, (ACOS( SIN(RADIANS(isnull(main.zc_lat,0))) * SIN(RADIANS(isnull(geo.zc_lat,0))) + COS(RADIANS(isnull(main.zc_lat,0))) * COS(RADIANS(isnull(geo.zc_lat,0))) * COS(RADIANS(isnull(main.zc_lon,0)) - RADIANS(isnull(geo.zc_lon,0))) ) * 6380) AS `distance` FROM tx_sdfilmbase_geodb main LEFT JOIN tx_sdfilmbase_geodb geo ON geo.zc_location_name LIKE '%frauenfeld%' WHERE main.zc_zip in(8500, 8501, 8502, 8503) ORDER BY `distance` ASC </code></pre> <p>OR</p> <pre><code>SELECT main.zc_zip, main.disabled, isnull( (ACOS( SIN(RADIANS(main.zc_lat)) * SIN(RADIANS(geo.zc_lat)) + COS(RADIANS(main.zc_lat)) * COS(RADIANS(geo.zc_lat)) * COS(RADIANS(main.zc_lon) - RADIANS(geo.zc_lon)) ) ,0) * 6380) AS `distance` FROM tx_sdfilmbase_geodb main LEFT JOIN tx_sdfilmbase_geodb geo ON geo.zc_location_name LIKE '%frauenfeld%' WHERE main.zc_zip in(8500, 8501, 8502, 8503) ORDER BY `distance` ASC </code></pre> <p>OR alternatively to using ISNULL()</p> <p>modify your original WHERE to say 'WHERE distance &lt; 20 <strong><em>OR distance is null</em></strong>'</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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