MySQL选择别名

时间:2012-05-19 11:21:19

标签: mysql

我在sql语句上有错误

SELECT temp.*  FROM 
    (SELECT th1.process_id,th2.process_id FROM `thread` as th1,`thread` as th2
    where (th1.thread_id=th2.thread_id)and 
    (th1.process_id!=th2.process_id) and 
    (th1.analysis_id='".$analysis_id."' ) and  
    (th2.analysis_id='".$analysis_id."' )) as temp 
     where ((t emp.p1  NOT IN (select pr.parent_process_id from process as pr 
            wherer pr.process_id=th2.process_id and (th2.analysis_id='".$analysis_id."' ) 
                and (pr.analysis_id='".$analysis_id."' )))  
        or  (temp.p2  NOT IN 
                         (select pr1.parent_process_id from process as pr1 
                           wherer pr1.process_id=th1.process_id  and (th2.analysis_id='".$analysis_id."' ) 
and (pr1.analysis_id='".$analysis_id."' ))))

1 个答案:

答案 0 :(得分:4)

使用wherer代替where时,您会出现明显的语法错误。

wherer pr.process_id=th2.process_id and

应该是

where pr.process_id=th2.process_id and

当MySQL报告类似于的错误时,请查看手册以了解在...附近使用的正确语法,请准确查看该位置或语法错误之前的字符。

  

检查与您的MySQL服务器版本对应的手册,以便在'wherer pr.process_id = tem.p2

附近使用正确的语法