Why my fields do not get updated with real time data in tables?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am having a quite strange behavior of my stored procedure.



My testing SQL query is as follows



    SET @Latitude = '45.512573';
SET @Longitude = '-122.661276';
SET @OrderDateTime = '2018-11-13 09:23:45';
SET @NumberOFRecords = 6;
SET @RecordsOffSet = 0;

SELECT
listings.LISTING_MAX_QUANTITY,
@TOTAL_ORDERS := SUM(order_items.ORDER_QUANTITY) AS TOTAL_ORDERS,
@REMAINING_ORDER_ITEMS := (listings.LISTING_MAX_QUANTITY - @TOTAL_ORDERS) AS REMAINING_ORDER_ITEMS
FROM listings
INNER JOIN order_items ON order_items.ORDER_LISTING_ID = listings.LISTING_ID AND DATE(order_items.ORDER_REQUIRED_DATE_TIME) = DATE(@OrderDateTime)
WHERE listings.LISTING_ID IN (SELECT listing_region.LIST_REGION_LISTING_ID FROM listing_region WHERE listing_region.LIST_REGION_REGION_ID IN (SELECT REGION_ID FROM region WHERE CONTAINS(REGION_POLYGON, point(@Latitude, @Longitude))))
AND listings.LISTING_MAX_QUANTITY > 99
AND TIME(@OrderDateTime) BETWEEN LISTING_START_TIME AND LISTING_END_TIME;


When I update the order_item tables with quantities, REMAINING_ORDER_ITEMS does not get updated in the first call. It is correct in the second call. Why is that? How does my query remember the last call?










share|improve this question


















  • 1





    In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:07











  • I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

    – PCG
    Nov 22 '18 at 17:24













  • Please show us how you use this stored procedure, in particular in relation with the update with quantities.

    – Lajos Arpad
    Nov 22 '18 at 17:25






  • 1





    check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:25











  • its the order where Used in JOIN. One the order is setup, it worked.

    – PCG
    Nov 25 '18 at 15:06


















0















I am having a quite strange behavior of my stored procedure.



My testing SQL query is as follows



    SET @Latitude = '45.512573';
SET @Longitude = '-122.661276';
SET @OrderDateTime = '2018-11-13 09:23:45';
SET @NumberOFRecords = 6;
SET @RecordsOffSet = 0;

SELECT
listings.LISTING_MAX_QUANTITY,
@TOTAL_ORDERS := SUM(order_items.ORDER_QUANTITY) AS TOTAL_ORDERS,
@REMAINING_ORDER_ITEMS := (listings.LISTING_MAX_QUANTITY - @TOTAL_ORDERS) AS REMAINING_ORDER_ITEMS
FROM listings
INNER JOIN order_items ON order_items.ORDER_LISTING_ID = listings.LISTING_ID AND DATE(order_items.ORDER_REQUIRED_DATE_TIME) = DATE(@OrderDateTime)
WHERE listings.LISTING_ID IN (SELECT listing_region.LIST_REGION_LISTING_ID FROM listing_region WHERE listing_region.LIST_REGION_REGION_ID IN (SELECT REGION_ID FROM region WHERE CONTAINS(REGION_POLYGON, point(@Latitude, @Longitude))))
AND listings.LISTING_MAX_QUANTITY > 99
AND TIME(@OrderDateTime) BETWEEN LISTING_START_TIME AND LISTING_END_TIME;


When I update the order_item tables with quantities, REMAINING_ORDER_ITEMS does not get updated in the first call. It is correct in the second call. Why is that? How does my query remember the last call?










share|improve this question


















  • 1





    In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:07











  • I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

    – PCG
    Nov 22 '18 at 17:24













  • Please show us how you use this stored procedure, in particular in relation with the update with quantities.

    – Lajos Arpad
    Nov 22 '18 at 17:25






  • 1





    check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:25











  • its the order where Used in JOIN. One the order is setup, it worked.

    – PCG
    Nov 25 '18 at 15:06














0












0








0








I am having a quite strange behavior of my stored procedure.



My testing SQL query is as follows



    SET @Latitude = '45.512573';
SET @Longitude = '-122.661276';
SET @OrderDateTime = '2018-11-13 09:23:45';
SET @NumberOFRecords = 6;
SET @RecordsOffSet = 0;

SELECT
listings.LISTING_MAX_QUANTITY,
@TOTAL_ORDERS := SUM(order_items.ORDER_QUANTITY) AS TOTAL_ORDERS,
@REMAINING_ORDER_ITEMS := (listings.LISTING_MAX_QUANTITY - @TOTAL_ORDERS) AS REMAINING_ORDER_ITEMS
FROM listings
INNER JOIN order_items ON order_items.ORDER_LISTING_ID = listings.LISTING_ID AND DATE(order_items.ORDER_REQUIRED_DATE_TIME) = DATE(@OrderDateTime)
WHERE listings.LISTING_ID IN (SELECT listing_region.LIST_REGION_LISTING_ID FROM listing_region WHERE listing_region.LIST_REGION_REGION_ID IN (SELECT REGION_ID FROM region WHERE CONTAINS(REGION_POLYGON, point(@Latitude, @Longitude))))
AND listings.LISTING_MAX_QUANTITY > 99
AND TIME(@OrderDateTime) BETWEEN LISTING_START_TIME AND LISTING_END_TIME;


When I update the order_item tables with quantities, REMAINING_ORDER_ITEMS does not get updated in the first call. It is correct in the second call. Why is that? How does my query remember the last call?










share|improve this question














I am having a quite strange behavior of my stored procedure.



My testing SQL query is as follows



    SET @Latitude = '45.512573';
SET @Longitude = '-122.661276';
SET @OrderDateTime = '2018-11-13 09:23:45';
SET @NumberOFRecords = 6;
SET @RecordsOffSet = 0;

SELECT
listings.LISTING_MAX_QUANTITY,
@TOTAL_ORDERS := SUM(order_items.ORDER_QUANTITY) AS TOTAL_ORDERS,
@REMAINING_ORDER_ITEMS := (listings.LISTING_MAX_QUANTITY - @TOTAL_ORDERS) AS REMAINING_ORDER_ITEMS
FROM listings
INNER JOIN order_items ON order_items.ORDER_LISTING_ID = listings.LISTING_ID AND DATE(order_items.ORDER_REQUIRED_DATE_TIME) = DATE(@OrderDateTime)
WHERE listings.LISTING_ID IN (SELECT listing_region.LIST_REGION_LISTING_ID FROM listing_region WHERE listing_region.LIST_REGION_REGION_ID IN (SELECT REGION_ID FROM region WHERE CONTAINS(REGION_POLYGON, point(@Latitude, @Longitude))))
AND listings.LISTING_MAX_QUANTITY > 99
AND TIME(@OrderDateTime) BETWEEN LISTING_START_TIME AND LISTING_END_TIME;


When I update the order_item tables with quantities, REMAINING_ORDER_ITEMS does not get updated in the first call. It is correct in the second call. Why is that? How does my query remember the last call?







mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 16:51









PCGPCG

186212




186212








  • 1





    In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:07











  • I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

    – PCG
    Nov 22 '18 at 17:24













  • Please show us how you use this stored procedure, in particular in relation with the update with quantities.

    – Lajos Arpad
    Nov 22 '18 at 17:25






  • 1





    check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:25











  • its the order where Used in JOIN. One the order is setup, it worked.

    – PCG
    Nov 25 '18 at 15:06














  • 1





    In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:07











  • I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

    – PCG
    Nov 22 '18 at 17:24













  • Please show us how you use this stored procedure, in particular in relation with the update with quantities.

    – Lajos Arpad
    Nov 22 '18 at 17:25






  • 1





    check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

    – Chowkidar Madhur Bhaiya
    Nov 22 '18 at 17:25











  • its the order where Used in JOIN. One the order is setup, it worked.

    – PCG
    Nov 25 '18 at 15:06








1




1





In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

– Chowkidar Madhur Bhaiya
Nov 22 '18 at 17:07





In such a large query, without any sample data, it is hard to figure out what is happening. It will be best if you setup a fiddle showcasing the problem being faced.

– Chowkidar Madhur Bhaiya
Nov 22 '18 at 17:07













I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

– PCG
Nov 22 '18 at 17:24







I need to figure out how to setup fiddle. Never done it. This query works perfectly fine in the second run as I stated. I don't understand is why it does not work in the first run after the table update.

– PCG
Nov 22 '18 at 17:24















Please show us how you use this stored procedure, in particular in relation with the update with quantities.

– Lajos Arpad
Nov 22 '18 at 17:25





Please show us how you use this stored procedure, in particular in relation with the update with quantities.

– Lajos Arpad
Nov 22 '18 at 17:25




1




1





check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

– Chowkidar Madhur Bhaiya
Nov 22 '18 at 17:25





check: db-fiddle.com ; it is mostly intuitive. You can also click on load example button at top to see how it works

– Chowkidar Madhur Bhaiya
Nov 22 '18 at 17:25













its the order where Used in JOIN. One the order is setup, it worked.

– PCG
Nov 25 '18 at 15:06





its the order where Used in JOIN. One the order is setup, it worked.

– PCG
Nov 25 '18 at 15:06












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435382%2fwhy-my-fields-do-not-get-updated-with-real-time-data-in-tables%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
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435382%2fwhy-my-fields-do-not-get-updated-with-real-time-data-in-tables%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?