Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [syntax]

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

0
votes
1answer
27 views

Trouble updating column with matching data from another table (3 diff. attempts: 1 w/out errors but no results, 2 with errors I don't understand) [closed]

Table 1 is 'z_scrapestorm_rentals' and table 2 is 'pcpao_cols'. They both have address columns named 'address_1_line_trunc' and 'address_one_line' respectively. Table z_scrapestorm_rentals: column ...
0
votes
1answer
13 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
310 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
24 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
25 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
29 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
85 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
61 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
57 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
155 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
27 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
268 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
169 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
318 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
65 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 ...
-1
votes
1answer
1k 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
39 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
0answers
31 views

Why is my first line of CREATE DATABASE in sql script is a syntax error? [closed]

CREATE DATABASE onlineshopping; CREATE TABLE stores ( store_number int, store_name text ); CREATE TABLE products ( product_number int, product_name text, amount int, ...
1
vote
1answer
266 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 ...
-3
votes
2answers
1k 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
63 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
479 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 ...
3
votes
2answers
63 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
101 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
30 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
427 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
526 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
343 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
439 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
26 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
248 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 ...
1
vote
2answers
65 views

Using exists in a query instead of a regular where

I saw this query that finds all the employees with more than one degree: select id, name from employee E where exists ( select * from academics A1, academics A2 where A1.emp_id = E.id and ...
4
votes
1answer
1k views

Using a CREATE TABLE AS SELECT how do I specify a WITH condition (CTE)?

There is an old and deprecated command in PostgreSQL that predates CREATE TABLE AS SELECT (CTAS) called SELECT ... INTO .... FROM, it supports WITH clauses / Common Table Expressions (CTE). So, for ...
24
votes
1answer
3k views

(NOLOCK) vs NOLOCK

I was investigating some blocking when I saw a query that looked something like this: SELECT SomeField FROM SomeTable NOLOCK I saw the NOLOCK and was curious how it could be blocking other queries, ...
0
votes
1answer
1k views

Loop inside of query in mysql procedure. Is it possible?

I have the following query: INSERT INTO major (key_1, key_2, ... , key_N) VALUES (v_1_1, v_1_2, v_1_3, ... , c_1_N) (v_2_1, v_2_2, v_2_3, ... , c_2_N) ... (v_K_1, v_K_2, v_K_3, ....
3
votes
1answer
174 views

Is there a way other than WKT to insert geometry to SQL Server?

I am using design data from *.dwg and *.dgn to insert geometries to SQL Server field which is set to geometry. All examples I see are using something called WKT which is a specification by a company ...
0
votes
1answer
2k views

Replace special character

I am trying to replace the character ' with the character ", using: UPDATE posts SET text = replace(text, ''', '"'); but: 1 errors were found during analysis. Ending quote ' was expected. (near ...
-1
votes
2answers
2k views

If function not exist then create function in SQL server [closed]

If not Exists (Select * from sys.objects where name ='FNLX_getDate' and type =N'FN') Create function [dbo].[FNLX_getDate]() returns Datetime as Begin ................. End When ...
0
votes
1answer
190 views

Why can't you do basic operations AFTER an aggregate in a window function? Like (max(x)+5), vs (5+max(x))

The syntax for aggregates and window functions is confusing, this does not work, SELECT (max(x)+5) OVER () FROM generate_series(1,10) AS t(x); While this works SELECT 5+max(x) OVER () FROM ...
0
votes
2answers
55 views

Facing error during query execution

I wrote a query in which I want to merge two tables and also create a log table for the data. as you can see at first I declared the @DimvisitorLog. This is for data log I checked all type of fields ...
0
votes
1answer
42 views

MySQL Syntax Error using FROM [closed]

I am getting the following syntax error when running the below query. Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ...
0
votes
1answer
37 views

Syntax for using Oracle Linked Server with USE keyword

I am working on a task where some tables from Oracle Peoplesoft have to pulled into SQL 2014. The concerned person gave me the following code and I see that in the end he mentions the comment Use /* ...
2
votes
1answer
76 views

How to properly filter columns after applying aggregate function

I find that I need to apply an aggregate a lot, but I don't want to show the aggregated value as well. So the best way to do this was to just nest the query to filter it out (like below) but there has ...
1
vote
1answer
42 views

Several SQL syntax questions

I have several small questions and I wrote some simple examples to clarify them: Will a nested aggregate take one value from from all groups? Like the minimal maximum of all groups? or the minimum ...
4
votes
2answers
518 views

Using max result as a value for a predicate in SQL

Say I want to find all the employees that earn more than all of the employees of Google, is it possible to use the result from max as if it was a single value and not a table like so? select person-...
12
votes
1answer
207 views

What allows SQL Server to trade an object name for a string passed to a system procedure

What causes it to be legal to pass an object name to the system stored procedure sp_helptext? What mechanism converts the object name to a string? e.g. -- works sp_helptext myproc sp_helptext [...
6
votes
2answers
2k views

Get all rows from table where JSON column contains a certain value

I'm struggling to get data from a JSON column in my PostgreSQL database. In our users table, we have a known_ips column, which is a JSON column, holding a flat array of IP addresses known for the ...
1
vote
1answer
67 views

Whats wrong with my query?

I know that this works for a database called DB01_20161110: ALTER AVAILABILITY GROUP AG1 ADD DATABASE DB01_20161110 I'm trying to add today's date automatically: DECLARE @DateString AS VARCHAR(...
0
votes
2answers
118 views

Execution Plan StatementText contains incorrect syntax

I have run an execution plan with management studio 2014 on mssql 2008 R2. To be able to better read the Selectstatement i right-clicked the plan to view it in xml. I noticed that some statements ...