Thanks for the info Jerry. =)
> -----Original Message----- > From: Jerry Schwartz [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 26, 2007 1:59 PM > To: 'Ed Lazor'; 'Octavian Rasnita'; mysql@lists.mysql.com > Subject: RE: select statement with variable for table_reference? > > Getting back to your original question, I don't know of any way you can > use > a variable as a table name directly. You can, however, pull off something > like this: > > mysql> set @table = "stage"; > Query OK, 0 rows affected (0.06 sec) > > mysql> set @stmt = CONCAT("SELECT * FROM ", @table); /* Arbitrarily > complex > stuff here */ > Query OK, 0 rows affected (0.05 sec) > > mysql> prepare foo from @stmt; > Query OK, 0 rows affected (0.03 sec) > Statement prepared > > mysql> execute foo; > +----------+------------+ > | stage_id | stage_name | > +----------+------------+ > | 1 | Imminent | > | 2 | Incoming | > | 3 | Follow Up | > | 4 | Eventual | > | 5 | Interested | > | 6 | Ongoing | > | 7 | Accts | > | 8 | Dump | > | 9 | Purchased | > +----------+------------+ > 9 rows in set (0.05 sec) > > Regards, > > Jerry Schwartz > The Infoshop by Global Information Incorporated > 195 Farmington Ave. > Farmington, CT 06032 > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]