如何在php mysql查询中添加where条件

时间:2016-04-04 14:17:46

标签: php mysql

我正在使用以下查询来获取最近的地方。但是如果我将where条件无效,那么错误就会出现。

 <audio id='myAudio'controls>
    <source id='mySource' src="song.mp3" type="audio/mpeg"/>
 </audio>


 $('#myAudio').on('ended', function() {
      $("#mySource").attr("src", Your_New_sourcel);
      var audio = $("#myAudio");      

      audio[0].pause();
      audio[0].load();
      audio[0].play();
 });

如果我添加where条件错误来了。请帮我如何为上述查询添加条件。

1 个答案:

答案 0 :(得分:0)

尝试使用HAVING条件替换WHERE子句:

SELECT attName, description, rating, 
                COMMENT , latitude, langtitude, openingTime, closingTime,(
                (
                ACOS( SIN(  ".$lat." * PI( ) /180 ) * SIN( latitude * PI( ) /180 ) + COS(  ".$lat." * PI( ) /180 ) * COS( latitude * PI( ) /180 ) * COS( (
                 ".$lang." - langtitude
                ) * PI( ) /180 ) ) *180 / PI( )
                ) *60 * 1.1515
                ) AS distance
                FROM attraction

                WHERE distance < 31

                ORDER BY distance 

然后将添加条件添加为AND this = that

HAVING子句通常与GROUP BY一起使用 - 您没有。

SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ...