SQLite User Forum

Result: near ”(”: syntax error
Login

Result: near "(": syntax error

(1) By BiplobKarmakar (biplob9842) on 2022-04-17 04:43:29 [link] [source]

SELECT Studentno, Name, dept from Student s where NOT EXISTS (

SELECT SectionNo FROM Section WHERE Instructor = 'Clark' AND (Year = 2018 OR Year = 2019) ) EXCEPT ( SELECT SectionNo FROM GradeReport G, WHERE G.StudentNo = S.StudentNo ) Anybody help?

(2) By Domingo (mingodad) on 2022-04-17 08:05:09 in reply to 1 [link] [source]

There is this tool https://github.com/facebookincubator/CG-SQL that can give better error messages than sqlite on several occasions like the one you having trouble.

====
cql --in test-error.sql
>cql --in test-error.sql
test-error.sql:18:1: error: syntax error, unexpected '(', expecting VALUES or SELECT
Parse errors found, no further passes will run.
>Exit code: 2
====
====
sqlite3 < "test-error.sql"
Parse error near line 1: near "(": syntax error
  'Clark' AND (Year = 2018 OR Year = 2019) ) EXCEPT ( SELECT       SectionNo FRO
                                      error here ---^
>Exit code: 1
====

(3) By anonymous on 2022-04-17 09:33:39 in reply to 1 [source]

The comma after GradeReport G looks dubious.

(4) By Keith Medcalf (kmedcalf) on 2022-04-17 20:24:24 in reply to 1 [link] [source]

Also compound queries must have the same tuple rank on both the left and right sides of the compound operator.
That is, to say more clearly, the number of columns in each sub-projection (the LHS and the RHS) must have the same number of columns.

(5) By Len Chisholm (LurkingKiwi) on 2022-04-18 14:40:10 in reply to 4 [link] [source]

Should the second parenthesis after 2019 be at the end? Is the except clause supposed to be removing SectionNo's from the sub query before the NOT EXISTS is applied?