Обсуждение: how to select
Ok, I should be posting this to the kindergarden list... but I didn't subscribe... I've connected to a database psql -l testdb showed tables \d show table schema \d testtable now I want to select #select someColumn from testtable I get nothing... no output, nothing... I'm used to MySQL where I can queries once connected... I'm sure I can do the same with PGSQL... FYI, I'm also using phpPGAdmin and I can run the SQL query there just fine -Jonathan
On 7/29/05, Jonathan Villa <jvilla@innovativesource.net> wrote: > now I want to select > #select someColumn from testtable > > I get nothing... no output, nothing... Try terminating the statement with ';'?
Ok, this is odd... I tried ending with a semicolon before, and received this error ERROR: parser: parse error at or near "select" I have to do it twice before I get it works...here's an example select project_name from project_group_list; ERROR: parser: parse error at or near "select" select project_name from project_group_list; ... ... ... that's odd... -Jonathan <quote who="Brian Wong"> > On 7/29/05, Jonathan Villa <jvilla@innovativesource.net> wrote: >> now I want to select >> #select someColumn from testtable >> >> I get nothing... no output, nothing... > > Try terminating the statement with ';'? >
On Fri, 2005-07-29 at 14:19, Jonathan Villa wrote: > Ok, this is odd... > > I tried ending with a semicolon before, and received this error > > ERROR: parser: parse error at or near "select" > > I have to do it twice before I get it works...here's an example > > select project_name from project_group_list; > ERROR: parser: parse error at or near "select" > select project_name from project_group_list; > ... > ... > ... > > that's odd... Not really. You already had a query queued up and ready to run. MySQL, by the way, works EXACTLY the same in this context. mysql> select * from test -> select * from test; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select * from test' at line 2
On Fri, Jul 29, 2005 at 02:19:07PM -0500, Jonathan Villa wrote: > I tried ending with a semicolon before, and received this error > > ERROR: parser: parse error at or near "select" > > I have to do it twice before I get it works...here's an example > > select project_name from project_group_list; > ERROR: parser: parse error at or near "select" > select project_name from project_group_list; If you tried to run commands before the first SELECT but didn't end them with a semicolon, then they were all being sent as a single command, which usually results in a syntax error. Here's an example -- notice the slightly different prompt on the second line, which shows that we're continuing a command started on a previous line: test=> SELECT project_name FROM project_group_list test-> SELECT project_name FROM project_group_list; ERROR: syntax error at or near "SELECT" at character 45 LINE 2: SELECT project_name FROM project_group_list; ^ test=> SELECT project_name FROM project_group_list; project_name -------------- Project A Project B Project C (3 rows) In psql you can clear the query buffer with \r: test=> SELECT project_name FROM project_group_list test-> \r Query buffer reset (cleared). test=> SELECT project_name FROM project_group_list; project_name -------------- Project A Project B Project C (3 rows) -- Michael Fuhr http://www.fuhr.org/~mfuhr/
On 7/29/05, Jonathan Villa <jvilla@innovativesource.net> wrote: > > Ok, this is odd... > > I tried ending with a semicolon before, and received this error > > ERROR: parser: parse error at or near "select" > > I have to do it twice before I get it works...here's an example > > select project_name from project_group_list; > ERROR: parser: parse error at or near "select" > select project_name from project_group_list; > ... > ... > ... > > that's odd... > > that's because you type a select without a semicolon then you write one with the semicolon so the parser think both are only one command but refused to execute that bad formed sentence and give you the error... then you put another sentence and, of cuorse it executed... you just show us 2 sentences one before the error and one after... am i right? -- Atentamente, Jaime Casanova (DBA: DataBase Aniquilator ;)
-Jonathan <quote who="Jaime Casanova"> > On 7/29/05, Jonathan Villa <jvilla@innovativesource.net> wrote: >> >> Ok, this is odd... >> >> I tried ending with a semicolon before, and received this error >> >> ERROR: parser: parse error at or near "select" >> >> I have to do it twice before I get it works...here's an example >> >> select project_name from project_group_list; >> ERROR: parser: parse error at or near "select" >> select project_name from project_group_list; >> ... >> ... >> ... >> >> that's odd... >> >> > > that's because you type a select without a semicolon then you write > one with the semicolon so the parser think both are only one command > but refused to execute that bad formed sentence and give you the > error... then you put another sentence and, of cuorse it executed... > > you just show us 2 sentences one before the error and one after... > > am i right? > > -- > Atentamente, > Jaime Casanova > (DBA: DataBase Aniquilator ;) > I feel about this small -> . Of course it's the semicolon... I guess I'm just used to MySQL where I would get this select user from table (hit enter) ->
On Fri, 2005-07-29 at 14:48, Jonathan Villa wrote: > -Jonathan > >> > >> > > > > that's because you type a select without a semicolon then you write > > one with the semicolon so the parser think both are only one command > > but refused to execute that bad formed sentence and give you the > > error... then you put another sentence and, of cuorse it executed... > > > > you just show us 2 sentences one before the error and one after... > > > > am i right? > > > > -- > > Atentamente, > > Jaime Casanova > > (DBA: DataBase Aniquilator ;) > > > > > > > > I feel about this small -> . > > Of course it's the semicolon... I guess I'm just used to MySQL where I would get this > > select user from table (hit enter) > -> No biggie. Postgresql is just a little more subtle: test=> select * from test test-> Notice the switch from => to ->