creating an alias for a tablename
I'm new to the ng, don't mean to step on anyone's toes, but I've
sesrched the archives with no success on this one.
I'd like to create aliases for tablenames. I don't mean a "table
alias", which is really a "row alias" (thanks to Bill Karwin for that
datum); that won't help me because I would still have to enter the
tablename at least once per query, per row. I mean an alias for a
tablename that can be used in queries, and stored either in the schema
somewhere or maybe applied once on a per-session basis.
I have *inherited* a db with some really stupidly long tablenames, so
writing queries is a hassle. Any typo in a tablename breaks the whole
query, of course. Here's an example of what I mean: Let's say I have
a table called tbl_data_reference_stock_22 ... here's a typical query:
SELECT tbl_data_reference_stock_22.uid,
tbl_data_reference_stock_22.store_id FROM tbl_data_reference_stock_22
WHERE tbl_data_reference_stock_22.session_id = '1'
I'd like to alias the tablename to "drs22". So the query would
become:
SELECT drs22.uid, drs22.store_id FROM drs22 WHERE drs22.session_id =
'1'
Is there a way to do this?
thanks in advance
--
FW
mySQL version 5.0
|