« first day (1382 days earlier)      last day (1276 days later) » 

5:30 AM
@TehShrike yea no problem thx !
 
 
9 hours later…
2:23 PM
If anyone available, could you kindly let me know whether my syntax is correct? I want to update the table flaggedcomments by setting the two columns (i.e. Prices_DateTime and Prices_Open) with the values obtained from table prices.
UPDATE flaggedcomments t1
INNER JOIN prices t2
ON t1.Tickers_Ticker_ID = t2.Tickers_Ticker_ID AND t1.Comments_Date = t2.Prices_DateTime
SET t1.Prices_DateTime = t2.Prices_DateTime, t1.Prices_Open = t2.Prices_Open
I've been waiting quite a while now, but the execution still not done. Maybe because my prices table has 1-2 million of records?
 
 
9 hours later…
11:47 PM
@Shyuan what are the schemas of flaggedcomments and prices? (the SHOW CREATE TABLE outputs for both tables)
 
@TehShrike Here:
CREATE TABLE `flaggedcomments` (
`Flaggedcomments_ID` int(11) NOT NULL AUTO_INCREMENT,
`Comment_ID` int(11) DEFAULT NULL,
`Comments_Date` datetime NOT NULL,
`Author` varchar(25) NOT NULL,
`Title` varchar(250) NOT NULL,
`Comments_Comment` text NOT NULL,
`Tickers_Ticker_ID` int(11) NOT NULL,
`Symbol` varchar(10) NOT NULL,
`Prices_DateTime` datetime DEFAULT NULL,
`Prices_Open` decimal(12,5) DEFAULT NULL,
`Threshold` varchar(10) DEFAULT NULL,
PRIMARY KEY (`Flaggedcomments_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1432 DEFAULT CHARSET=utf8;
 
@Shyuan and the prices table?
 
obtaining.. :)
I did a test using LEFT JOIN rather than INNER JOIN, it seems it took me 3 hours to UPDATE the flaggedcomments but it took only 1 hour to show if i use SELECT. Is LEFT JOIN more suitable in this case because there are null cells?
CREATE TABLE `prices` (
`Prices_ID` int(11) NOT NULL AUTO_INCREMENT,
`Prices_Date` date NOT NULL,
`Prices_Time` time NOT NULL,
`Prices_Open` decimal(12,5) DEFAULT NULL,
`Prices_High` decimal(12,5) DEFAULT NULL,
`Prices_Low` decimal(12,5) DEFAULT NULL,
`Prices_Close` decimal(12,5) DEFAULT NULL,
`Prices_Volume` int(11) NOT NULL,
`Tickers_Ticker_ID` int(11) NOT NULL,
`Prices_DateTime` datetime DEFAULT NULL,
PRIMARY KEY (`Prices_ID`,`Tickers_Ticker_ID`),
UNIQUE KEY `Prices_Date` (`Prices_Date`,`Prices_Time`,`Prices_Open`,`Prices_High`,`Prices_Low`,`Prices_Close`,`Prices_Volume`,`Tickers_Ticker_
 
@Shyuan Do you want to set the values to NULL when there is no matching row in prices?
 
Yes
 
11:58 PM
@Shyuan Then you should use the LEFT JOIN, yeah
 
What would be the result using INNER JOIN, if there's no matching row in prices?
@TehShrike Thank you very much for your confirmation :)
 
@Shyuan the query would only affect rows in flaggedcomments that had matching rows in prices.
And yeah, I'd expect that query to take a very long time
 

« first day (1382 days earlier)      last day (1276 days later) »