问题描述
我有大约 15 个表,每个表包含大约 10、000 行和大约 30 列.我希望我网站的用户能够搜索部件号或产品/描述并显示结果.不管它在哪个表中.
每个产品页面与每个对应表的名称相同.因此,如果找到产品,它只会显示一个指向正确页面的链接(文件名是表的名称).
我们就不能这样:
query = "在 dbase.tables 中查找 $q";?
如果 $q 存在于表中,则返回找到它的表的名称?
感谢任何帮助!
谢谢
推荐答案
如果所有表都具有相同的结构,您也许可以这样做.(这听起来像是一个简单的手动分区方案.)
加入多个可以使用的表
SELECT * FROM tbl1 UNION ALL SELECT * FROM tbl2 ...
为了获得简单的访问方法,您可以在该连接上创建一个视图:
CREATE VIEW alltables AS SELECT * ... UNION ...
从未测试过这个.但是这个视图将有助于 SELECT * FROM alltables WHERE find($q)... - 当然,您仍然需要对列进行有效查询.
问题描述
I have about 15 tables, each table containing about 10, 000 rows and about 30 columns. I want the users of my site to be able to search for a Part Number, or a product/description and display the results. Regardless of which table it's in.
Each product page is the same as the name of each corresponding table. So if a product is found, it will just display a link to the correct page (the filename is the name of the table).
Can't we just do something like:
query = "find $q in dbase.tables"; ?
And if $q exists in a table, return the name of the table it was found in?
Any help is appreciated!
Thank you
推荐答案
If all the tables have the same structure you might be able to do that. (That sounds like it's a simplistic manual partitioning scheme.)
Anway to join multiple tables you can use
SELECT * FROM tbl1 UNION ALL SELECT * FROM tbl2 ...
And to get your simple access method you might create a view on that concatenation:
CREATE VIEW alltables AS SELECT * ... UNION ...
Not ever tested this. But this view would then facilitate SELECT * FROM alltables WHERE find($q)... - you'd still need a valid query for the columns of course.