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

learn more… | top users | synonyms

1
vote
1answer
26 views

Timestamp Difference - Syntax Error - Condtitional Selects

Here is what I have right now SELECT name, admin, reason, unban, FROM_UNIXTIME(date) AS datetime, HOUR(difference) AS HRemain, MINUTE(difference) AS MRemain FROM ...
1
vote
1answer
20 views

Postgresql uuid syntax error

I am trying to insert/update a foreign key field which is also a uuid to use the correct fk id for this set of data: zuri=# ALTER TABLE newarts ALTER COLUMN jurisdiction_id SET DEFAULT ...
2
votes
1answer
50 views

What is the purpose of the Save Transaction statement?

I read up on SAVE TRANSACTION, but I'm not completely sure I understand it. I'm aware of the concept of transactions as far as BEGIN, COMMIT, and ROLLBACK, but this is a new one. It sounds almost ...
0
votes
0answers
43 views

MySQL/MariaDB: Can I drop KEY declatations in sql dump for CREATE TABLE for foreign keys?

I prepare Liquibase schema creation changelog for legacy DB. I started with SQL dump and refined it by little sed processing so I have only CREATE TABLE statements. It looks like: CREATE TABLE ...
0
votes
1answer
70 views

Syntax error with concat in trigger near signal statement

Please help me with syntax for MySQL 5.6. For some reason I get the error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
0
votes
1answer
215 views

SQL80001 - incorrect syntax near ')'

In the below code (that I've inherited), I'm getting the message "SQL80001 - incorrect syntax near ')'", the error being on the third line from the bottom with the + sign. I've looked at THIS SO ...
0
votes
1answer
49 views

How to select the first unique data type in a table

Sorry for the messy layout question. This is my first post. I have the following table structure under ORACLE database List item Row A B Date 1 X X 01-2012 2 ...
1
vote
1answer
87 views

Teradata view with “With Clause” syntax

I am trying to a view with "With" clause in Teradata but it is not allowing to create a view. Please suggest with any options. Given below is the query which I have tried: create view ...
0
votes
1answer
59 views

Teradata sql syntax from date to quarter

Need a Teradata sql syntax to extract quarter from a date. Given below is the expected output Date: (YYYY-MM-DD) 2015-09-12 2015-05-22 2014-12-15 Output 3Q15 2Q15 4Q14 Query which I have ...
1
vote
1answer
49 views

SSIS Derived Column Conditional Time Modification

I'm using SSIS to transfer data from a MySQL database to a SQL Server one. There's one point that I'm currently stuck on, however. MySQL TIME datatype supports values greater than or equal to ...
0
votes
0answers
6 views

Reason of poor performance of ANSI joins in Oracle 9i

Please before flagging as duplicate, read the last paragraphs. In an Oracle 9i database this query runs in 0.18 seconds: select count(*) from dba_synonyms s,dba_objects t where ...
2
votes
1answer
93 views

Converting old SQL Server outer join syntax

I'm a Power Builder (PB) developer. I've migrated PB from 10 .5 to 12.5, and now I need to migrate the stored procedures from SQL Server 2005 to 2012 as well. I get a invalid expression error when I ...
1
vote
2answers
156 views

Use array expression from subquery in ANY() condition

I have a relatively complicated query with a subquery fetching an array like so: ... ARRAY(SELECT category_id FROM category_schedule_con con WHERE s.id = con.schedule_id ORDER BY category_id) ...
1
vote
2answers
78 views

Weird Syntax Error [closed]

I'm working with MySQL 5.6 on a Ubuntu 14.04 server. Checking in this online syntax checker: https://sql.treasuredata.com/ The syntax checker tool throws the exception: mismatched input 'NOT' ...
0
votes
1answer
20 views

Is capitalization of SQL commands/keywords required, expected or completely optional? [closed]

Also, is it done automatically in some environments?
0
votes
1answer
79 views

How can we drop a constraint without losing the automatically created index?

How can we drop a constraint without losing the automatically created index? If it's possible using a single query.
1
vote
1answer
84 views

select members with the longest running absence streak

I have a database containing a table that stores attendance data, and its columns are member_id and datetime_attended. And another table storing members info, which is made up by the columns id and ...
2
votes
1answer
379 views

Arithmetic overflow error varchar to numeric

I'm getting an arithmetic overflow error and I can't seem to find out the case. I've recently had to adjust some stored procedures, to allow for dates in the future to be put in. The following part ...
2
votes
2answers
99 views

Can't select 2 tables at the same time

I have a pesId (peopleId) column at pessoas (people) where is stored data from medics and patient. Also I have a table that stores medical consult information like Date, patient id, medic id and ...
3
votes
2answers
526 views

Why is it truncate table, and not simply truncate?

Upon reviewing some of our code a colleague posited that he was annoyed at always having to write TRUNCATE TABLE when there is no real other usage for TRUNCATE. Googling this, I indeed can not find a ...
3
votes
3answers
167 views

SQL SSIS syntax question

What do you call the following expression? (TableName == NULL) ? "0" : TableName I have a sense of what it does, but would like to look up the whole syntax definition, however as there is no real ...
0
votes
1answer
332 views

“Incorrect Syntax near S” in Stored Procedure [closed]

I'm creating a SQL Server stored procedure and getting error Incorrect Syntax near S I'm not able to find the exact reason of the error. CREATE PROCEDURE RPT_IVR_CALL_SUMMARY ...
2
votes
2answers
211 views

Upgrading a database from SQL Server 2005 to 2012 uncovered a syntax error

I recently upgraded from SQL Server 2005 to 2012. During validation however, a bug was discovered. A certain trigger was coded as follows: CREATE TRIGGER [dbo].[trigger] on [dbo].[foo] FOR UPDATE, ...
0
votes
1answer
71 views

Help converting a MySQL query to postgres

Is it possible to do this query in postgresql? SET @p:= 0; UPDATE t SET x=CEIL((@p:= @p + 1) / $n) ORDER BY id DESC; I'm struggling with the variable syntax. I tried: \set p 0 update t set ...
0
votes
1answer
156 views

How to only display a variable in PHP inside a MySQL query when it has a content or when a condition is true?

How do I only display $mon or any variable when it has content? whenever i use this syntax and for example, monday must contain the number 1 and tuesday would contain number 2 and the other ones have ...
0
votes
2answers
61 views

How can I move backups location?

I have a seemingly easy question. How can I move a xxx.bak file to another location with T-sql? I have a job that takes a copy from database a to c:mycopy/copy1/a.bak and I want to create a step that ...
0
votes
1answer
97 views

Syntax Error In Postgresql Function [closed]

Why am I getting: ERROR: syntax error at or near "'SELECT '" In: CREATE OR REPLACE FUNCTION GetListings (lon double precision, lat double precision, schemas name[]) RETURNS TABLE( schema ...
7
votes
2answers
8k views

How to create a temporary table using VALUES in PostgreSQL

I am learning PostgreSQL and trying to figure out how to create a temporary table or a WITH declaration that can be used in place of regular table, for debugging purposes. I looked at the ...
10
votes
3answers
4k views

Why do we use Group by 1 and Group by 1,2,3 in SQL query?

In SQL queries, we do use Group by clause to apply aggregate functions. But what is the purpose behind using numeric value instead of column name with Group by clause? For example: Group by 1.
2
votes
2answers
690 views

Lines starting with colons in SQL Server

Playing around with DB projects, Visual Studio generated a change script with the following lines: GO SET ANSI_NULLS, ANSI_PADDING --etc.; SET NUMERIC_ROUNDABORT OFF; GO :setvar DatabaseName "Foo" ...
1
vote
1answer
1k views

How to join a table with a table valued function?

I have a user defined function: create function ut_FooFunc(@fooID bigint, @anotherParam tinyint) returns @tbl Table (Field1 int, Field2 varchar(100)) as begin -- blah blah end Now I want to join ...
-1
votes
1answer
69 views

what is the syntax for insert trigger?

I am very new to sql. feel a little stupid to ask this question Say I have this table Warehouse(shipperid, name , state). Then I define another table warehouse_maine (shipperid, name, state) which ...
5
votes
1answer
259 views

View designer strange join syntax

I have a data warehouse with a lot of views built in with the SSMS view designer. Viewing the syntax, the FROM clauses are unintelligible to me because the ON statements do not follow straight after ...
0
votes
2answers
140 views

using update query with subquery in Oracle sql

I have an update query where I am trying to update a field but for more than one record, I am trying a join but it doesn't work. Below I get multiple values that come back from the select statement ...
-1
votes
1answer
68 views

alternative foreign key syntax

in mysql you can assign primary key constraint to a column using two different syntax: after the column is defined, separated by coma, optionally in a new line id int auto_increment, primary key(id) ...
2
votes
1answer
44 views

Translate SQL Server update statement to MySQL

I have a development environment with MySQL and a production environment with SQL Server. This update statement works with SQL Server: UPDATE THIS SET <list_of_column_assignments> FROM ...
0
votes
3answers
3k views

I'm trying to use a variable in Oracle PL/SQL, but I'm getting an error. What's wrong here?

I come from an SQL Server background and I'm trying to figure out how to use Oracle PL/SQL variables. I'm trying to declare a variable and then select that variable. It sounds simple, but I am doing ...
1
vote
1answer
288 views

Why do ASC and DESC come *after* a CASE clause?

This query works: DECLARE @Ordering NVARCHAR(50) SET @Ordering = 'aggregateid' DECLARE @OrderDirectionInt INT SET @OrderDirectionInt = 0 --1 SELECT * FROM ( SELECT ROW_NUMBER() OVER ...
0
votes
1answer
71 views

Drastic change in query speed when changing from Oracle 9i to ANSI outer join syntax

I am working on simplifying a query originally written for Oracle 9i. In the process I changed the join syntax from the Oracle 9i syntax to ANSI. The names of the tables and columns have been changed ...
0
votes
1answer
395 views

MySQL JDBC does not behaves as the MySQL Workbench

I'm running the following from the MySQL Workbench, and from my local tomcat using jdbc. START TRANSACTION; CREATE SCHEMA IF NOT EXISTS `ROOT`; CREATE TABLE IF NOT EXISTS `ROOT`.`all_tables` ( ...
0
votes
1answer
61 views

Is this statement syntactically correct? [closed]

$q = "SELECT var1, var2, var3 FROM tablename WHERE var_a = '$var_a' AND var_b = '$var_b' AND ( ( var1 = '$var1' AND var2 = '$var2' ) OR ( var1 = '$var2' AND var2 = '$var1' ) )"; This ...
0
votes
1answer
39 views

SQL where clause effect on table? [closed]

I have sql query as select sourceIP, sum(sourceBytes) from flows group by sourceIP order by sum(sourceBytes) desc This brings result (dummy) as:- sourceIp SourceBytes 192.168.1.2 100 ...
2
votes
1answer
98 views

What column is this alias referring to?

I've read the following code a few times trying to figure out what it is doing. "A right outer join is that which returns the unmatched rows from the right tables with matched rows from the left ...
0
votes
2answers
959 views

MySQL Syntax Error When Creating a Trigger

I am trying to create a trigger but I am getting a syntax error and I am not really sure why I am. CREATE TRIGGER Section_Insert AFTER INSERT ON Section -> FOR EACH ROW BEGIN -> INSERT ...
2
votes
1answer
519 views

what is '#' in create table statement?

I recently saw a statement like: CREATE TABLE #tbl_AR_Data I wanted to know what is the purpose of the symbol # (NUMBER SIGN, hash, pound sign) in this statement?
3
votes
1answer
80 views

Doing a join to search geolocation points in zones

I have a series of geolocation points in a table, and a series of "zones" in another; I'd like to do a join to identify which zone each point belongs in (if at all.) Points table looks like: ...
-1
votes
1answer
38 views

How to retrieve time in XML [closed]

In this XML : <CD> <title>Essential Collection </title> <artist>Lee Dorsey</artist> <tracks> <track>Ya Ya</track> <track>Do Re Mi</track> ...
0
votes
2answers
85 views

Is my JOIN syntax not valid? And have I understood JOIN correctly?

I've been reading up a bit regarding JOINs. And i just noticed that I've been writing the syntax a little bit different. Although I don't think there's any problem with it, I would like to hear your ...
1
vote
5answers
138 views

More efficient way to write multiple “AND”?

Anyone know a way to write this in a different manner ? SELECT tableA.NO FROM tableA WHERE tableA.NO IN (SELECT GRI_NO FROM tableBB WHERE GRO_NO =62) AND tableA.NO IN (SELECT GRI_NO FROM tableBB ...
7
votes
1answer
17k views

Syntax of INNER JOIN nested inside OUTER JOIN vs. query results

TLDR; If you look at the 2 execution plans, is there an easy answer to which is better? I purposefully did NOT create indexes so it's easier to see what's happening. Following up on my previous ...