Update Rows based on Select from same Table
I have PervasiveSQL DB with a table with Item Selling Costs Listed by StoreCode. Data looks like the data below
StoreCore ItemCode LastPurchAmt
001 2201 78.75
002 2201 75.0
003 2201 75.0
05 2201 0.0
07 2201 75.0
08 2201 78.75
09 2201 75.0
10 2201 75.0
They requested that i set the LastPurchAmt for each item = to the LastPurchAmt of Store 001.
I've read through more update examples and tried more variations for the update statement than i care to remember but i just can't seem to get this.
This Statement:
Update MultiStoreTrn as UpdateTrn
join (select ItemCode, LastPurchAmt from MultiStoreTrn where StoreCode = '001') as ValueTrn
on UpdateTrn.ItemCode = ValueTrn.ItemCode
set UpdateTrn.LastPurchAmt = ValueTrn.LastPurchAmt
where UpdateTrn.StoreCode <> '001';
Returns a Error Message:
[LNA][Pervasive][ODBC Engine Interface]A table or view name must be specified for update.
This Code:
Update MultiStoreTrn as UpdateTrn
set UpdateTrn.LastPurchAmt = (Select LastPurchAmt from MultiStoreTrn where StoreCode = 001 and ItemCode = UpdateTrn.ItemCode);
Works but it updates all the values to Zero
I have tried this code as well:
Update MultiStoreTrn
set MultiStoreTrn.LastPurchAmt = ValueTrn.LastPurchAmt
from (select ItemCode, LastPurchAmt from MultiStoreTrn where storecode = 001) as ValueTrn
where MultiStoreTrn.StoreCode <> 001 and MultiStoreTrn.ItemCode = ValueTrn.ItemCode;
It runs without errors but updates nothing.
Any ideas what i'm missing :(
Thanks for the Time Reading and Answering...
pervasive pervasive-sql
add a comment |
I have PervasiveSQL DB with a table with Item Selling Costs Listed by StoreCode. Data looks like the data below
StoreCore ItemCode LastPurchAmt
001 2201 78.75
002 2201 75.0
003 2201 75.0
05 2201 0.0
07 2201 75.0
08 2201 78.75
09 2201 75.0
10 2201 75.0
They requested that i set the LastPurchAmt for each item = to the LastPurchAmt of Store 001.
I've read through more update examples and tried more variations for the update statement than i care to remember but i just can't seem to get this.
This Statement:
Update MultiStoreTrn as UpdateTrn
join (select ItemCode, LastPurchAmt from MultiStoreTrn where StoreCode = '001') as ValueTrn
on UpdateTrn.ItemCode = ValueTrn.ItemCode
set UpdateTrn.LastPurchAmt = ValueTrn.LastPurchAmt
where UpdateTrn.StoreCode <> '001';
Returns a Error Message:
[LNA][Pervasive][ODBC Engine Interface]A table or view name must be specified for update.
This Code:
Update MultiStoreTrn as UpdateTrn
set UpdateTrn.LastPurchAmt = (Select LastPurchAmt from MultiStoreTrn where StoreCode = 001 and ItemCode = UpdateTrn.ItemCode);
Works but it updates all the values to Zero
I have tried this code as well:
Update MultiStoreTrn
set MultiStoreTrn.LastPurchAmt = ValueTrn.LastPurchAmt
from (select ItemCode, LastPurchAmt from MultiStoreTrn where storecode = 001) as ValueTrn
where MultiStoreTrn.StoreCode <> 001 and MultiStoreTrn.ItemCode = ValueTrn.ItemCode;
It runs without errors but updates nothing.
Any ideas what i'm missing :(
Thanks for the Time Reading and Answering...
pervasive pervasive-sql
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52
add a comment |
I have PervasiveSQL DB with a table with Item Selling Costs Listed by StoreCode. Data looks like the data below
StoreCore ItemCode LastPurchAmt
001 2201 78.75
002 2201 75.0
003 2201 75.0
05 2201 0.0
07 2201 75.0
08 2201 78.75
09 2201 75.0
10 2201 75.0
They requested that i set the LastPurchAmt for each item = to the LastPurchAmt of Store 001.
I've read through more update examples and tried more variations for the update statement than i care to remember but i just can't seem to get this.
This Statement:
Update MultiStoreTrn as UpdateTrn
join (select ItemCode, LastPurchAmt from MultiStoreTrn where StoreCode = '001') as ValueTrn
on UpdateTrn.ItemCode = ValueTrn.ItemCode
set UpdateTrn.LastPurchAmt = ValueTrn.LastPurchAmt
where UpdateTrn.StoreCode <> '001';
Returns a Error Message:
[LNA][Pervasive][ODBC Engine Interface]A table or view name must be specified for update.
This Code:
Update MultiStoreTrn as UpdateTrn
set UpdateTrn.LastPurchAmt = (Select LastPurchAmt from MultiStoreTrn where StoreCode = 001 and ItemCode = UpdateTrn.ItemCode);
Works but it updates all the values to Zero
I have tried this code as well:
Update MultiStoreTrn
set MultiStoreTrn.LastPurchAmt = ValueTrn.LastPurchAmt
from (select ItemCode, LastPurchAmt from MultiStoreTrn where storecode = 001) as ValueTrn
where MultiStoreTrn.StoreCode <> 001 and MultiStoreTrn.ItemCode = ValueTrn.ItemCode;
It runs without errors but updates nothing.
Any ideas what i'm missing :(
Thanks for the Time Reading and Answering...
pervasive pervasive-sql
I have PervasiveSQL DB with a table with Item Selling Costs Listed by StoreCode. Data looks like the data below
StoreCore ItemCode LastPurchAmt
001 2201 78.75
002 2201 75.0
003 2201 75.0
05 2201 0.0
07 2201 75.0
08 2201 78.75
09 2201 75.0
10 2201 75.0
They requested that i set the LastPurchAmt for each item = to the LastPurchAmt of Store 001.
I've read through more update examples and tried more variations for the update statement than i care to remember but i just can't seem to get this.
This Statement:
Update MultiStoreTrn as UpdateTrn
join (select ItemCode, LastPurchAmt from MultiStoreTrn where StoreCode = '001') as ValueTrn
on UpdateTrn.ItemCode = ValueTrn.ItemCode
set UpdateTrn.LastPurchAmt = ValueTrn.LastPurchAmt
where UpdateTrn.StoreCode <> '001';
Returns a Error Message:
[LNA][Pervasive][ODBC Engine Interface]A table or view name must be specified for update.
This Code:
Update MultiStoreTrn as UpdateTrn
set UpdateTrn.LastPurchAmt = (Select LastPurchAmt from MultiStoreTrn where StoreCode = 001 and ItemCode = UpdateTrn.ItemCode);
Works but it updates all the values to Zero
I have tried this code as well:
Update MultiStoreTrn
set MultiStoreTrn.LastPurchAmt = ValueTrn.LastPurchAmt
from (select ItemCode, LastPurchAmt from MultiStoreTrn where storecode = 001) as ValueTrn
where MultiStoreTrn.StoreCode <> 001 and MultiStoreTrn.ItemCode = ValueTrn.ItemCode;
It runs without errors but updates nothing.
Any ideas what i'm missing :(
Thanks for the Time Reading and Answering...
pervasive pervasive-sql
pervasive pervasive-sql
asked Jan 2 at 9:15
badboytazzbadboytazz
132
132
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52
add a comment |
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003774%2fupdate-rows-based-on-select-from-same-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003774%2fupdate-rows-based-on-select-from-same-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What version of Pervasive PSQL are you using? I ran through your queries and the last two worked for me. I think the last query is the best option
– mirtheil
Jan 2 at 15:52