简体   繁体   中英

SQL syntax error near “WHERE” 2

Query:

select distinct R1.name, R2.name
from (
    (
    select Ra.mID mID, Re.rID rID, Re.name name
    from Rating Ra join Reviewer Re using (rID)
    ) R1
    ,
    (
    select Ra.mID mID, Re.rID rID, Re.name name
    from Rating Ra join Reviewer Re using (rID)
    ) R2
where R1.mID = R2.mID and R1.rID > R2.rID;

Result:

Query failed to execute: near "where": syntax error

I am guessing the problem has something to do with the pointer variables in the FROM clause that are referred to in the WHERE clause, but I can't figure it out. I haven't been very wary of my WHEREs recently...

There is a mismatch in the number of opening and closing brackets in the provided SQL.

There may also be other issues, but that's less clear without knowing what db server / version you are running.

Check your php version as your query is perfect. It may possible because some php version is not supporting sub query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM