I tried the following query:
mysql> INSERT INTO tm_visitor (VDT,VID, NAME, CONTACT) values(REPLACE(LE
FT(NOW(), 10), '-', ''),(SELECT LPAD(COALESCE(MAX(VID) + 1, 000001), 6, '0') FRO
M tm_visitor),'yatin','9876543120');
but I get the following error.
ERROR 1093 (HY000): You can't specify target table 'tm_visitor' for update in FROM clause`
What is going wrong and how do I fix it?
INSERT INTO tm_visitor (VDT,VID, NAME, CONTACT)
SELECT REPLACE(LEFT(NOW(), 10), '-', ''),
LPAD(COALESCE(MAX(VID) + 1, 000001), 6, '0'),
'yatin','9876543120'
FROM tm_visitor