dahousecat Posted October 29, 2009 Share Posted October 29, 2009 Hi There, I hope someone can help as I'm getting rather confused... I have two tables: ClicksData ClickDate Clicks Impressions OperatorID and Operators ID SiteType I have written this SELECT query that successfully filters, joins and groups both tables: SELECT `CD`.`ClickDate`, `CD`.`Clicks`, `CD`.`Impressions`, `OP`.`SiteType`, `OP`.`ID` FROM `clicksdata` AS `CD` LEFT JOIN `operators` As OP ON `CD`.`OperatorID` = `OP`.`ID` WHERE `CD`.`ClickDate` >= '2009-09-01' AND `CD`.`ClickDate` <= '2009-11-01' AND `OP`.`ID` = 48 AND `OP`.`SiteType` = 'Free Bingo' GROUP BY `CD`.`ClickDate` However I would like to turn this into an UPDATE query so I can store the result in a temp table for later use. I'm not even sure if it's possible to combine all these functions in one query - can anyone advise? Cheers, Felix Link to comment https://forums.phpfreaks.com/topic/179471-update-and-join-and-group-by/ Share on other sites More sharing options...
Mchl Posted October 29, 2009 Share Posted October 29, 2009 I never tried this, but you should be able to do something like UPDATE tableToUpdate AS t, (SELECT ... ) AS s SET t.field1 = s.field1, ... WHERE t.ID = s.ID Link to comment https://forums.phpfreaks.com/topic/179471-update-and-join-and-group-by/#findComment-946924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.