PDA

View Full Version : replace into


sidhighwind
Wed 17th Mar '04, 8:42am
I am trying to do the following


REPLACE INTO test (tally,day,cid)
SELECT tally,day,cid from test where cid='sws' and day='2004-03-17'


but it's giving me this error:


Error
SQL-query :

REPLACE INTO test( tally,
DAY , cid )
SELECT tally,
DAY , cid
FROM test
WHERE cid = 'sws' AND
DAY = '2004-03-17'

MySQL said:


#1066 - Not unique table/alias: 'test'

i just fixed the query to look like this and now it's giving me the following error.


SQL-query :

REPLACE INTO test( tally, `day` , cid )
SELECT t2.tally, t2.day, t2.cid
FROM test AS t2
WHERE t2.cid = 'sws' AND t2.day = '2004-03-17'

MySQL said:


#1093 - INSERT TABLE 'test' isn't allowed in FROM table list


Can anyone help me and tell me what i'm doing wrong?

Thanks in advance!