insert into
keyword_history (
keyword_id,
searchengine,
location,
"4",
curdate()
)
select
keyword_id,
searchengine,
location
from
keyword_history
where
history_id = 21
Basically, what I'm开发者_JS百科 trying to do is :
- select a row from a table
- insert it again but this time with current date and the value "4"
Yes you can. You may want to try the following instead:
INSERT INTO keyword_history
(
keyword_id,
searchengine,
location,
rec_date,
currentrank
)
SELECT keyword_id,
searchengine,
location,
curdate(),
'4'
FROM keyword_history
WHERE history_id = 21;
EDIT: Updated field names as per comment below.
Try this; it seems you're putting values in your field list inadvertently...
insert into keyword_history
(keyword_id, searchengine, location, your_number_col, your_date_col)
select keyword_id, searchengine, location, '4', curdate()
from keyword_history
where history_id = 21
精彩评论