我需要选择 n 表中的所有行,其中 n >以毫秒为单位访问数据集。单个查询会导致错误“定义的字段太多”。我的猜测是它超过了255场限制。
SELECT * FROM ((((((((((((((((Forms
LEFT JOIN Layouts ON Layouts.Name = Forms.Name)
LEFT JOIN Layout ON Layout.Name = Forms.Name)
LEFT JOIN Form ON Form.Name = Forms.Name)
LEFT JOIN Sections ON Sections.ID] = Form.ID)
LEFT JOIN Checks ON Checks.ID = Form.ID)
LEFT JOIN Dates ON Dates.ID = Form.ID)
LEFT JOIN Combos ON Combos.ID = Form.ID)
LEFT JOIN Labels ON Labels.ID = Form.ID)
LEFT JOIN Flash ON Flash.ID = Form.ID)
LEFT JOIN Links ON Links.ID = Form.ID)
LEFT JOIN Groups ON Groups.ID = Form.ID)
LEFT JOIN Lists ON Lists.ID = Form.ID)
LEFT JOIN Pictures ON Pictures.ID = Form.ID)
LEFT JOIN Grids ON Grids.ID = Form.ID)
LEFT JOIN Shapes ON Shapes.ID = Form.ID)
LEFT JOIN Texts ON Texts.ID = Form.ID)
WHERE Forms.Name = 'History'
我从一些SO用户那里读到,这种访问大量列/字段的方法是不恰当或不好的做法。在许多表都相关的情况下获取大量字段的正确方法或思路是什么?
答案 0 :(得分:0)
您的查询中的问题是select *
,而不是联接。如果Form.Id
确实是您要加入的字段,那么这些联接可能很好。
而是列出select:
中的列SELECT col1, col2, col3 . . .
FROM ((((((((((((((((Forms
LEFT JOIN Layouts ON Layouts.Name = Forms.Name)
LEFT JOIN Layout ON Layout.Name = Forms.Name)
LEFT JOIN Form ON Form.Name = Forms.Name)
LEFT JOIN Sections ON Sections.ID] = Form.ID)
LEFT JOIN Checks ON Checks.ID = Form.ID)
LEFT JOIN Dates ON Dates.ID = Form.ID)
LEFT JOIN Combos ON Combos.ID = Form.ID)
LEFT JOIN Labels ON Labels.ID = Form.ID)
LEFT JOIN Flash ON Flash.ID = Form.ID)
LEFT JOIN Links ON Links.ID = Form.ID)
LEFT JOIN Groups ON Groups.ID = Form.ID)
LEFT JOIN Lists ON Lists.ID = Form.ID)
LEFT JOIN Pictures ON Pictures.ID = Form.ID)
LEFT JOIN Grids ON Grids.ID = Form.ID)
LEFT JOIN Shapes ON Shapes.ID = Form.ID)
LEFT JOIN Texts ON Texts.ID = Form.ID)
WHERE Forms.Name = 'History'