简体   繁体   中英

Missing right parenthesis subquery

This query returns missing right parenthesis although when I run the inside query it runs fine.

 select t.id 
 from
 (select
  v.id,
  max(c.image_type_id),
  max(vp.x), 
  max(vp.y),
  max(vp.z)
  FROM
  v,
  vp,
  c,
  WHERE v.id = vp.id 
  AND v.id = c.id
  group by v.id;) t

Remove semicolon ; and ,

SELECT t.id 
FROM
(SELECT
 v.id,
 max(c.image_type_id),
 max(vp.x), 
 max(vp.y),
 max(vp.z)
 FROM
 v,
 vp,
 c       // HERE the comma
 WHERE v.id = vp.id 
 AND v.id = c.id
 GROUP BY v.id) t  // HERE the semicolon

Just remove semicolon and last comma. Try to run below code.

 select t.id 
 from
 (select
  v.id,
  max(c.image_type_id),
  max(vp.x), 
  max(vp.y),
  max(vp.z)
  FROM
  v,
  vp,
  c
  WHERE v.id = vp.id 
  AND v.id = c.id
  group by v.id) t

Get rid of that semi-colon.

The semi-colon basically says to the interpreter "this is the end of an sql statement." If you have a semi-colon in the middle of your sql, it's going to treat everything before and everything after each as individual statements.

The semicolon at the end is culprit.

select t.id 
 from
 (select
  v.id,
  max(c.image_type_id),
  max(vp.x), 
  max(vp.y),
  max(vp.z)
  FROM
  v,
  vp,
  c,
  WHERE v.id = vp.id 
  AND v.id = c.id
  group by v.id)t

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