Need help with a SQL Query!

INSERT INTO jos_fb_messages_text (mesid, message) SELECT jos_fb_messages.id, replys.reply FROM replys, jos_fb_messages WHERE jos_fb_messages.thread = replys.id AND WHERE jos_fb_messages.time = UNIX_TIMESTAMP(replys.time) and WHERE jos_fb_messages.name = replys.poster

I am trying to move some old forums to Kunena Forums and I am trying to insert a message from the replys table to the jos_fb_messages_text table but I don’t have the mesid in the replys table but in the jos_fb_messages table so I have to match the reply id to jos_fb_messages.thread. The problem is I want to do this for all the records but it won’t allow me to do that, so I was wandering how I would do this with a cursor of some sort?

the qry will work for all the records…
if not then… there is data quality issue:)

this is your query, reformatted –

INSERT 
  INTO jos_fb_messages_text 
     ( mesid
     , message ) 
SELECT jos_fb_messages.id
     , replys.reply 
  FROM replys
INNER
  JOIN jos_fb_messages 
    ON jos_fb_messages.thread = replys.id 
   AND jos_fb_messages.time = UNIX_TIMESTAMP(replys.time) 
   AND jos_fb_messages.name = replys.poster

please explain what this means –

The problem is I want to do this for all the records but it won’t allow me to do that

Wrong query up top, the right one is below

top INSERT INTO jos_fb_messages_text (mesid, message) SELECT jos_fb_messages.id, replys.reply FROM replys, jos_fb_messages WHERE jos_fb_messages.thread = replys.id AND jos_fb_messages.time = UNIX_TIMESTAMP(replys.time) AND jos_fb_messages.name = replys.poster