Forum Moderators: coopster

Message Too Old, No Replies

MySQL - data changes with subqueries

MySQL - data changes with subqueries

         

joedub

12:27 pm on May 26, 2005 (gmt 0)

10+ Year Member



Hello,

I am having trouble with performing an INSERT, from SELECTED data.

The following query i can get to work fine:

INSERT INTO months_domains ( MonthDomainID, MonthHits )
( SELECT domains.DomainID, domains.DomainHits FROM domains )

But when i try to add a value not retrieved from the select statement, i can't keep the query legal. Below is my attempt

INSERT INTO months_domains ( MonthDate, MonthDomainID, MonthHits )
( '26-5-2005', ( SELECT domains.DomainID, domains.DomainHits FROM domains ) )

any help appreciated

cheers

MamaDawg

1:14 pm on May 26, 2005 (gmt 0)

10+ Year Member



INSERT INTO months_domains ( MonthDate, MonthDomainID, MonthHits )
( '26-5-2005', ( SELECT domains.DomainID, domains.DomainHits FROM domains ) )

Try putting the date into the "SELECT" statement ...

(SELECT '26-05-2005', domains.DomainID, domains.DomainHits FROM domains))

Or use one of the date functions like CURDATE() to generate the correct date. It may also be complaining about not using 2 digits for the month in your date string.

joedub

1:28 pm on May 26, 2005 (gmt 0)

10+ Year Member



Cheers, putting the date in the select got it!