Click here to Skip to main content
15,900,461 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to update Oracle DB from SQL server through link server? Pin
Jörgen Andersson22-Sep-16 21:38
professionalJörgen Andersson22-Sep-16 21:38 
AnswerRe: How to update Oracle DB from SQL server through link server? Pin
hmanhha25-Sep-16 21:25
hmanhha25-Sep-16 21:25 
QuestionSQL Server Stored Procedure - Wait for a Table to be Created Pin
David_4122-Sep-16 9:29
David_4122-Sep-16 9:29 
Question[Help] How to create database for control Process in manufacturing company Pin
VaTo Tran21-Sep-16 2:05
VaTo Tran21-Sep-16 2:05 
QuestionIssue on communicating data from two difference system with different names Pin
chaurasiashankar19-Sep-16 19:47
chaurasiashankar19-Sep-16 19:47 
AnswerRe: Issue on communicating data from two difference system with different names Pin
Mycroft Holmes19-Sep-16 20:17
professionalMycroft Holmes19-Sep-16 20:17 
AnswerRe: Issue on communicating data from two difference system with different names Pin
Jörgen Andersson19-Sep-16 20:17
professionalJörgen Andersson19-Sep-16 20:17 
QuestionMariaDB und Updates with select same table Pin
RMolino17-Sep-16 8:33
RMolino17-Sep-16 8:33 
Hello,

I'm having some problems getting an update running. I have done similar updates some times without problems (MySql instead of MariaDB). Maybe I'm too tired today to see the problem, it was a long working day...
Maybe someone can illuminate me Smile | :)

Table:
SQL
CREATE TABLE ps_data.test (
  Test_ID int(11) NOT NULL AUTO_INCREMENT,
  Idx int(11) NOT NULL,
  Grp int(11) DEFAULT NULL,
  PRIMARY KEY (Test_ID)
)
ENGINE = INNODB
AUTO_INCREMENT = 10
AVG_ROW_LENGTH = 1820
CHARACTER SET utf8
COLLATE utf8_unicode_ci;


Sample-Data:
SQL
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(1, 1, 1);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(2, 2, 1);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(3, 3, 1);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(4, 4, 1);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(5, 5, 2);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(6, 6, 2);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(7, 7, 2);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(8, 8, 2);
INSERT INTO ps_data.test(Test_ID, Idx, Grp) VALUES
(9, 9, 2);


Update commands (none working):
SQL
UPDATE test
SET Idx=(SELECT COALESCE(MAX(tbl.Idx), 0)+1 FROM (SELECT * FROM test) tbl WHERE tbl.Grp=1)
WHERE Test_ID=1 

UPDATE test
SET Idx=(SELECT COALESCE(MAX(tbl.Idx), 0)+1 FROM (SELECT * FROM test WHERE Grp=1) tbl)
WHERE Test_ID=1 

UPDATE test t, (SELECT * FROM test WHERE Grp=1) tbl
SET t.Idx= (SELECT COALESCE(MAX(tbl.Idx), 0)+1)
WHERE t.Test_ID=1 


The first update command produces even a null result on the MAX() function. Strange...

Best Regards,
Raul

modified 17-Sep-16 15:09pm.

AnswerRe: MariaDB und Updates with select same table Pin
Mycroft Holmes17-Sep-16 11:22
professionalMycroft Holmes17-Sep-16 11:22 
GeneralRe: MariaDB und Updates with select same table Pin
RMolino18-Sep-16 0:42
RMolino18-Sep-16 0:42 
QuestionMajor differences between sql server express and sql server localdb Pin
Tridip Bhattacharjee5-Sep-16 23:20
professionalTridip Bhattacharjee5-Sep-16 23:20 
AnswerRe: Major differences between sql server express and sql server localdb Pin
Eddy Vluggen6-Sep-16 0:29
professionalEddy Vluggen6-Sep-16 0:29 
QuestionSQL While loop Pin
Mphirana31-Aug-16 4:40
Mphirana31-Aug-16 4:40 
AnswerRe: SQL While loop Pin
Victor Nijegorodov31-Aug-16 21:57
Victor Nijegorodov31-Aug-16 21:57 
AnswerRe: SQL While loop Pin
jschell1-Sep-16 7:10
jschell1-Sep-16 7:10 
GeneralRe: SQL While loop Pin
Mphirana1-Sep-16 9:40
Mphirana1-Sep-16 9:40 
QuestionExposing API VS Stored Procedure Pin
Java Lead31-Aug-16 4:29
Java Lead31-Aug-16 4:29 
AnswerRe: Exposing API VS Stored Procedure Pin
Richard MacCutchan31-Aug-16 4:46
mveRichard MacCutchan31-Aug-16 4:46 
Question.mdf file not updated? Pin
kmllev26-Aug-16 16:59
kmllev26-Aug-16 16:59 
GeneralRe: .mdf file not updated? Pin
Richard MacCutchan26-Aug-16 21:07
mveRichard MacCutchan26-Aug-16 21:07 
AnswerRe: .mdf file not updated? Pin
Eddy Vluggen29-Aug-16 4:06
professionalEddy Vluggen29-Aug-16 4:06 
GeneralRe: .mdf file not updated? Pin
kmllev29-Aug-16 5:16
kmllev29-Aug-16 5:16 
QuestionHow to speedup the execution of a query in Sql Server? Pin
Abhijit Mindcraft22-Aug-16 22:52
Abhijit Mindcraft22-Aug-16 22:52 
AnswerRe: How to speedup the execution of a query in Sql Server? Pin
Mycroft Holmes22-Aug-16 23:11
professionalMycroft Holmes22-Aug-16 23:11 
AnswerRe: How to speedup the execution of a query in Sql Server? Pin
David Mujica23-Aug-16 5:35
David Mujica23-Aug-16 5:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.