Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem of MySQL query : Can't get the correct data

$
0
0
Hi,guys.
Now I got two tables which is temp_monthly_sales_stock and con_sales. temp_monthly_sales_stock is a temporary table that I created to store temporary data.
Now the problem is I want to update temp_monthly_sales_stock table by matching the ArtNo from temp_monthly_sales_stock and con_sales table.
But when I execute this query,then nothing. I mean the result shown is "0 row(s) affected".

UPDATE temp_monthly_sales_stock SET Day1=(SELECT SUM(quantity) FROM con_sales WHERE DAY(receiptdate)='2' AND MONTH(receiptdate)='9' AND YEAR(receiptdate)='2012') WHERE EXISTS(SELECT con_sales.ArtNo FROM con_sales WHERE temp_monthly_sales_stock.ArtNo=con_sales.ArtNo)


And I tried this query
UPDATE temp_monthly_sales_stock SET Day1=(SELECT SUM(quantity) FROM con_sales WHERE DAY(receiptdate)='2' AND MONTH(receiptdate)='9' AND YEAR(receiptdate)='2012') WHERE temp_monthly_sales_stock.ArtNo=con_sales.ArtNo

this give me an error of "Unknown table 'con_sales' in where clause".

Can someone guide me how to solve this problem?

Viewing all articles
Browse latest Browse all 51036

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>