Re: [PHP-DB] wild cards for table names in a MySQL select statement From: Alexey V. Borzov (borz_off <email protected>)
Date: 11/18/00

Hello Michael,

1) Well, first of all, "47 columns" sounds like "way too much". You
should probably dig up some tutorial on database normalization and
re-design your DB structure.
2) There is no way to do this using standard SQL. But, you can
do something along the lines of:
CREATE VIEW wholesale_view
AS SELECT ws_something, [45 more columns...], ws_something_else
FROM lsp_size_price;
and then use only:
SELECT * FROM wholesale_view;
The same goes for rt_%

Oh, wait! It is YourSQL, isn't it?
::shaking head:: Tough luck, man... You CAN'T do that...

Saturday, November 18, 2000, 12:35:14 AM, you wrote:

MH> This question is born of sheer laziness, but an answer may be lurking out
MH> there.

MH> We have a MySQL table that lists prices. There are 47 columns that begin
MH> with "WS" (for wholesale prices), and 47 corresponding columns that begin
MH> with "RT" (for retail prices).

MH> What we would like to do to avoid writing them all out everyplace, is to
MH> select all fields starting with "WS" or all fields starting with "RT".

MH> It's not a big deal, but it would be quite convenient if we could use some
MH> sort of wild card in the SELECT statement.

MH> We've tried "SELECT lsp_size_price.WS%" and "SELECT lsp_size_price.WS*" (two
MH> logical choices) but they only give us syntax errors.

MH> If anyone could help us out, it would be appreciated.

-- 
Yours, Alexey V. Borzov, webmaster of RDW.ru

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>