我正在尝试为网站开发搜索页面,但无法提出单个查询。
以下是这十个表及其字段的列表
tmp_auction_auto
id订单类别制造商型号价格price_type位置年份run_type门安全气囊齿轮发动机马力气缸驱动器燃料颜色abs电子窗口climatcontrol磁盘舱口板计算机报警器turte parkingcontrol调节器leathersalon导航中央锁定椅子水力学noprice租赁交换定制状态其他联系tmp_auction_estate id订单类型交易价格price_type price_sqm noprice城市地址区高度维修条件项目目的地土地阳台有双重斜坡屋顶会议stairs_total楼梯室卧室阳台sanitary_arr凉廊壁炉空调车库停车land_destination建筑物distance_central_street distance_tbilisi库房按摩浴室浴室淋浴桑拿家具技术电话互联网发电机池businesscenter吃网络库存wardobe电梯燃气热水加热对讲电缆报警系统入口安全窗口防盗安全双工三联卫星厨房展示land_railway land_electricity land_gas land_water land_drainage status其他联系
tmp_auction_other id订单标题价格price_type noprice info contact
tmp_news id lang title content date
tmp_pages id lang title content date
tmp_polls id name question answers ip
tmp_presentation id lang title order
tmp_sitemap id parent lang title link order
我知道我可以用任何顺序(不良做法)为每个表写多个查询,然后将它组合到PHP数组中进行输出,但我更需要专业的方法来处理这个主题。
P.S。我不想使用memcache,solr,sphinxs等libs(服务器不支持那些)
答案 0 :(得分:1)
I guess you can join these tables and create a view into which the data obtained fom the joined tables can be saved. Now the search must be conducted on this view which will speed up the search.
For eg.
mysql> SELECT CONCAT(UPPER(supplier_name), ' ', supplier_address) FROM suppliers;
+-----------------------------------------------------+
| CONCAT(UPPER(supplier_name), ' ', supplier_address) |
+-----------------------------------------------------+
| MICROSOFT 1 Microsoft Way |
| APPLE, INC. 1 Infinate Loop |
| EASYTECH 100 Beltway Drive |
| WILDTECH 100 Hard Drive |
| HEWLETT PACKARD 100 Printer Expressway |
+-----------------------------------------------------+
CREATE VIEW suppformat AS
SELECT CONCAT(UPPER(supplier_name), ' ', supplier_address) FROM suppliers;
mysql> SELECT * FROM suppformat;
+-----------------------------------------------------+
| CONCAT(UPPER(supplier_name), ' ', supplier_address) |
+-----------------------------------------------------+
| MICROSOFT 1 Microsoft Way |
| APPLE, INC. 1 Infinate Loop |
| EASYTECH 100 Beltway Drive |
| WILDTECH 100 Hard Drive |
| HEWLETT PACKARD 100 Printer Expressway |
+-----------------------------------------------------+
Please check this link which will give you some idea of views
[http://www.techotopia.com/index.php/An_Introduction_to_MySQL_Views][1]
[1]: http://www.techotopia.com/index.php/An_Introduction_to_MySQL_Views