I have stored procedure in my database and i need to look up a table and cross reference an id, then using the returned row i need to insert information into another table, but i cant seem to use the infomation from the lookup into the insert. This is what i have..
BEGIN
#Routine body goes here...
SET @UID = uid;
SET @UIDTOFB = uid_to;
SET @SQLTEST = CONCAT('SELECT users.user_auto_id FROM users WHERE users.user_fb_uid= @UIDTOFB LIMIT 1');
PREPARE sqlcmd from @SQLTEST;
EXECUTE sqlcmd;
INSERT INTO challenges(challenge_from_uid, challenge_to_uid, challenge_dateadded) VALUES(@UID, @SQLTEST.users.user_auto_id, now());
SET @LASTID = LAST_INSERT_ID();
SELECT @LASTID as id;
END
any help would be much appreciated!