use a variable for table name in mysql sproc

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-05-02T18:09:37Z Indexed on 2010/05/02 18:17 UTC
Read the original article Hit count: 214

I'm trying to pass a table name into my mysql stored procedure to use this sproc to select off of different tables but it's not working...

this is what I"m trying:

CREATE PROCEDURE `usp_SelectFromTables`(
 IN TableName varchar(100)
)
BEGIN
        SELECT * FROM @TableName;
END

I've also tried it w/o the @ sign and that just tells me that TableName doesn't exist...which I know :)

© Stack Overflow or respective owner

Related posts about mysql

Related posts about stored-procedures