Re: wild cards for table names in a MySQL select statement

From: Date: Sat, 18 Nov 2000 08:23:17 +0000
Subject: Re: wild cards for table names in a MySQL select statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4533@lists.php.net to get a copy of this message
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 MH> 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

« previous php.db (#4533) next »