Questions tagged [syntax]

The set of rules that define the combinations of symbols that are considered to be correctly structured for that language.

Filter by
Sorted by
Tagged with
0
votes
0answers
19 views

Is it possible to create an SQL transaction that rollbacks on syntax errors?

In may day-to-day job, I often have to create SQL files containing minor changes (no DDL operation usually) in order to migrate those to production databases easily. The problem is, even with syntax ...
0
votes
1answer
23 views

Set the file name in “SELECT … INTO DUMPFILE”

I am trying to write a query to dump a single LONGBLOB data into a file. SELECT data FROM table WHERE id = 123 INTO DUMPFILE fileName which data, fileName, and id are the fields in the table. SQL ...
2
votes
0answers
11 views

Relational Algebra: how to express the combination of aggregation and projection?

Here I have a table, I would like to query the average salary of departments, the SQL statement should be select dept_name, avg(salary) from employee I try to express this SQL in relational algebra....
2
votes
1answer
42 views

Does the ANSI SQL Standard allow filters or parameters in JOIN conditions?

Does the ANSI Standard find the following SQL sinppet syntactically correct? I am interested specifically in the last line: SELECT name, dept_name FROM employee JOIN department ON employee....
0
votes
2answers
53 views

Postgresql, commas in string_agg function [closed]

Need FIELD like this, with ' and without , at the end of whole field. {name:'color',value:'red'},{name:'width',value:'300 ml'} Tried string_agg(distinct '{name:\'' || param_name || '\',value:\'' ||...
1
vote
1answer
52 views

max_stack_depth error in postgresql

I am fairly new to PostgreSQL and would appreciate any help and recommendations. I'm running the following function to update a table: $BODY$ DECLARE commercial_period date := (SELECT periods....
0
votes
1answer
35 views

Query to get the physical file name of the database

Im trying to get the physical file name of a database, and when i query sys.database_files, under the physical file name column, you get the whole path (ie. S:\Program Files\Microsoft SQL Server\...
0
votes
1answer
34 views

Syntax error in simple trigger

I have a SQLite table with these fields among others Fld_QuoteNumberRoot string Fld_Revision integer Fld_QuoteNumber string I need to fill ...
1
vote
0answers
16 views

Syntax Error on Set Clause in Update Query [closed]

This seems like a simple query, but currently it returns a syntax error: UPDATE tablename SET description = "a nice description" WHERE tableid = 2; The error I get says: ERROR: column "a nice ...
0
votes
0answers
10 views

ST_MapAlgebra count if full extent

I want to count MAX value from two rasters with different extent. I use this code: DELETE FROM vitr.pove; INSERT INTO vitr.pove (rast) SELECT ST_Tile(ST_MapALgebra(a_c1d1.rast, 1, b_c2d2.rast, 1, '...
5
votes
1answer
252 views

Can’t run a function against EXEC

My SQL Server book says you can't run a function inside EXEC and shows an example: DECLARE @NumberOfLetters int = 15; EXEC(‘SELECT LEFT(Name,’ + CAST(@NumberOfLetters AS varchar) + ‘) AS ShortName ...
11
votes
1answer
829 views

Can we put an equal sign (=) after aggregate functions in Transact-SQL?

I have encountered a script like this: set @sum = sum = (case when somecol1 is null then DATEDIFF(d,[somecol2],somecol3) else 0 end) I can't understand the meaning of the equal sign (=) after the ...
-2
votes
1answer
44 views

Query syntax error [closed]

I tried a lot but can't find what is wrong with this query, It gave me this error: Incorrect syntax near ')' WITH cte AS ( SELECT * FROM ( ...
1
vote
1answer
61 views

What are some consequences of putting quotes in a WHERE clause for an integer column?

I have a table with a column some_column of data type integer. I've noticed that my PostgreSQL 10.6 instance is smart enough to interpret both of the queries below as same: select * from my_table ...
-1
votes
1answer
61 views

MySQL: Syntax error around foreign key assignment [closed]

I put the following into DB Fiddle in an attempt to debug it. The error is below Results Schema Error: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds ...
0
votes
1answer
42 views

Select query with nested relationships

I have the following 3 PostgreSQL tables: wallet: +----+--------+-----------+-----------+--------+ | id | name | createdAt | updatedAt | locked | +----+--------+-----------+-----------+--------+ | ...
1
vote
1answer
45 views

Can DBA create a public synonym for a table that has the same name as an existing table

Suppose a DBA created a public synonym for a table and named it hr. The user also created a table with the same name hr. If a user performs a query like the following statement: select * from hr; ...
1
vote
0answers
26 views

Escape from Alcatraz: SqlAnywhere to MSSQL [closed]

Is there a migration tool that actually works for SAP SqlAnywhere 17 to MSSQL (any recent version)? Searching for "sqlanywhere mssql migration" yields a variety of hits including SQL Server ...
1
vote
1answer
73 views

Postgres 10.0 upsert syntax error not sure what to google for

Postgres 10.0 table: pcr=> \d tableFindOld Table "public.tablefindold" Column | Type | Collation | Nullable | Default ----------+--...
0
votes
1answer
51 views

Missing data in SQL Server

I need to find the data that is present in Oracle, but missing from SQL Server. I have tried the below query, but am getting the following error: The multi-part identifier "PS.TXN_ID" could not be ...
1
vote
1answer
983 views

Syntax error when trying to add columns to table in DBeaver (postgresql)

I've tried this a few different ways but every time I get a syntax error when trying to add columns to a table. I'm new to databases so it's probably something basic that I'm doing wrong, but I just ...
5
votes
1answer
390 views

Unfamiliar syntax - Query with Parameters in Braces at the beggining

I have run sp_WhoIsActive on one of our servers using the following syntax: sp_whoisactive @get_plans = 1, @show_sleeping_spids = 0, @get_outer_command = 1, @get_locks = 1 and found a spid with the ...
0
votes
1answer
193 views

MySQL syntax error 1064 near IN stored procedure

an aspiring DBA Here. I'm trying to create a stored procedure for a query I'm running. It is a memsql server which is MySQL based. The procedure is as such: delimiter // CREATE PROCEDURE ...
1
vote
1answer
27 views

how to extract difference between timestamps

SQL greenhorn alarm: I have a table with timestamp information (44 rows) and I now would like to calculate and extract the delta between any two consecutive rows. How can I do this? I select my data ...
0
votes
1answer
32 views

Receiving error while creating stored procedure to insert Excel files into a table

I was wondering if you could tell me what is wrong with my query? The parameter @TableName is an input parameter. Why do I have to declare it again? CREATE PROCEDURE [dbo].[OpenExcel] @FileName ...
6
votes
2answers
327 views

Is there a way to partially initialize a TYPE?

I have created a custom type: CREATE TYPE my_type as(name text, street text, location text); Initializing such a type is easy: SELECT ROW('a', 'b', 'c')::my_type; I am wondering if there is an ...
3
votes
1answer
49 views

What does @ signify in a query expression?

What does the @ symbol signify in this sql expression? update some_table set some_number=(@some_number+1) where some_id=1; It seems to return the same result as: update some_table set some_number=...
-1
votes
2answers
279 views

check syntax errors on mysql dump file

I have an issue to check syntax error on MySQL dump file. Please inform me a tool or command to check syntax on MySQL dump file. Thank You.
0
votes
1answer
62 views

How to make subtraction without repeating the subqueries? [closed]

I need to efficiently obtain: players who play more than one world cup and who have never been champion. primary-key | foreign-key | pk-and-fk PLAYER<player_id, player_name, country_player, .....
2
votes
1answer
443 views

Query keeps on giving me 'unknown column' issue

I've researched quite a lot for the past few days about this error that I'm getting but I cannot really fix it so I was hoping somebody could help me. The query keeps on telling me: ERROR 1054 (42S22)...
2
votes
1answer
32 views

Consults and counts in multiple databases

I'm not very familiar with mysql advanced queries, because I'm more of a designer as a developer. My problem - I have 3 tables: Clients ------------------------------------------------------ | id | ...
1
vote
2answers
1k views

Understanding Variations on Multiple Joins

I have two versions of a multiple join which produce identical results. The five tables are: customers ← sales ← saleitems → paintings → artists The arrows (hopefully) show the relationship between ...
0
votes
1answer
290 views

Does MySQL or MariaDB support double literals (double precision)?

MySQL seems to support double precision The FLOAT and DOUBLE types represent approximate numeric data values. MySQL uses four bytes for single-precision values and eight bytes for double-precision ...
5
votes
1answer
659 views

How to add a named constraint in Oracle SQL?

I have a table. I need to add a NOT NULL constraint to one of the columns. This is my best attempt at a solution: alter table clookup add CONSTRAINT lookup_9 NOT NULL (clookup_col) This produces ...
1
vote
1answer
69 views

returning a null value instead of no value

Why are the last 2 selects (cases 5 and 6) returning a null value? This may seem like a trivial question but it actually caused a bug in one of my joins where I expected rows to be filtered out by ...
2
votes
1answer
5k views

How do I write a hex literal in PostgreSQL?

How do you write a hex literal in PostgreSQL? Like say I want 0xCC, if I do; SELECT 0xCC; xcc ----- 0 (1 row) So PostgreSQL is parsing the xcc as an alias.
-1
votes
1answer
234 views

SQLITE3 Commandline Tool SQL UPDATE Query syntax problem

I have two databases with identical table structures Dest.db = main Source.db = src the table is called colorramp structure of colorramp is ID | name | xml | favorite main.colorramp needs ...
1
vote
1answer
543 views

MariaDB 10.2: Why does Count(*) work, but not Count(t.*)

I have a table containing transaction details which I am importing from several vendor-provided daily reports.. I want to be sure that I am not skipping any of the files (one file per day) as I do ...
-2
votes
2answers
3k views

Why am I getting an error while creating index command in postgres? [closed]

Here is the table on which I am trying to create index create table domestic( id SERIAL primary key NOT NULL, Dto int DEFAULT NULL, Dfrom int DEFAULT NULL, courierType varchar(100) DEFAULT NULL, ...
-1
votes
1answer
74 views

Help: 'converting 'row number over partition' to 'SIMPLE' sql

PREFACE: Hi, I'm studying SQL, I haven't been taught about partitioning with this feature, so I'd like to understand how to solve this problem using 'basic' SQL statements. My relation is like this: ...
0
votes
1answer
943 views

phpMyAdmin trigger error

The following oddly does work, but shows an error in PhpMyAdmin... (see image below) (in the definition block as seen in the image) BEGIN SET NEW.expiry = DATE_ADD(NOW(), INTERVAL NEW.duration ...
2
votes
2answers
67 views

MongoDB find() not getting anything

I have a collection as follows: { "_id" : ObjectId("5a6d9a1ee183f06dfd91dbf0"), "date" : "20180126", "oid" : "000", "aid" : "0000000000", "currentavalible" : "7", "...
7
votes
1answer
110 views

Do any SQL dialects permit the logical sequence of SELECT clauses?

SELECT in ISO/IEC-standard SQL prescribes the following syntactical order for the sub-clauses: SELECT projection-expressions FROM sources WHERE predicate-expression GROUP BY key-...
1
vote
1answer
44 views

Creating a MySQL function gives an error

This is the error after running this script: MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use ...
0
votes
1answer
664 views

Restoring multiple files to multiple database with pg_restore

I have multiple dump files and want to restore them with single command. something like this pg_restore -h localhost -p 5432 -U postgres -d gl_election gl_world gl_tourism -c "gl_election" ...
3
votes
1answer
1k views

Making dynamic queries for linked server in SQL Server

I want to create a dynamic query in SQL Server which will run on linked server. I am trying to do it as follows. USE [MYDB] GO DECLARE @company AS nvarchar(50); DECLARE @id nvarchar(MAX); DECLARE @...
0
votes
2answers
749 views

Return list of values in conditional where clause

I'm trying to filter a table based on a parameter that determines which list of values are allowed for a certain column. For @Parameter = 1 we want MyColumn to be either FirstValue or SecondValue; for ...
-1
votes
1answer
772 views

MySQL command to view records on 15 minutes basis [closed]

I want to select some records on the basis of 15 minutes time interval. Is it possible using any sql command. I am confused while doing it with div 900 sec and timestamp. Please help.
1
vote
1answer
29 views

Can't debug this simple SQL Statement

I'm importing data into a MySQL table using LOAD DATA LOCAL INFILE. I.ve done this on another table without difficulty, and I copied the stmt and just changed the table name and the fields. Here's the ...
0
votes
1answer
364 views

Insert Into Statement With OpenQuery [closed]

I have constructed the following syntax but I keep getting an error of: Msg 156, Level 15, State 1, Line 26 Incorrect syntax near the keyword 'INSERT'. What do I need to change in my syntax so ...