Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否有“的限制?”;加入;或;其中;还是SQL查询的长度?_Php_Sql_Elgg - Fatal编程技术网

Php 是否有“的限制?”;加入;或;其中;还是SQL查询的长度?

Php 是否有“的限制?”;加入;或;其中;还是SQL查询的长度?,php,sql,elgg,Php,Sql,Elgg,实际上,我试图从elgg数据库中获取基于多个连接的数据。它生成了一个非常大的查询,其中包含大量的JOIN语句,并且查询从未响应 SELECT distinct e.* from test_entities e JOIN test_metadata m1 on e.guid = m1.entity_guid JOIN test_metastrings ms1 on ms1.id = m1.name_id JOIN test_metastrings mv1 on mv1.id = m1.val

实际上,我试图从elgg数据库中获取基于多个连接的数据。它生成了一个非常大的查询,其中包含大量的JOIN语句,并且查询从未响应

SELECT distinct e.* from test_entities e 
JOIN test_metadata m1 on e.guid = m1.entity_guid 
JOIN test_metastrings ms1 on ms1.id = m1.name_id 
JOIN test_metastrings mv1 on mv1.id = m1.value_id 
JOIN test_objects_entity obj on e.guid = obj.guid 
JOIN test_metadata m2 on e.guid = m2.entity_guid 
JOIN test_metastrings ms2 on ms2.id = m2.name_id 
JOIN test_metastrings mv2 on mv2.id = m2.value_id 
JOIN test_metadata m3 on e.guid = m3.entity_guid 
JOIN test_metastrings ms3 on ms3.id = m3.name_id 
JOIN test_metastrings mv3 on mv3.id = m3.value_id 
JOIN test_metadata m4 on e.guid = m4.entity_guid 
JOIN test_metastrings ms4 on ms4.id = m4.name_id 
JOIN test_metastrings mv4 on mv4.id = m4.value_id 
JOIN test_metadata m5 on e.guid = m5.entity_guid 
JOIN test_metastrings ms5 on ms5.id = m5.name_id 
JOIN test_metastrings mv5 on mv5.id = m5.value_id 
JOIN test_metadata m6 on e.guid = m6.entity_guid 
JOIN test_metastrings ms6 on ms6.id = m6.name_id 
JOIN test_metastrings mv6 on mv6.id = m6.value_id 

where ms1.string='expire_date' and mv1.string <= 1272565800 and ms2.string='homecity' and 
mv2.string LIKE "%dasf%" and ms3.string='schoolname' and mv3.string LIKE "%asdf%" 

and ms4.string='award_amount' and mv4.string <= 123 and ms5.string='no_of_awards' and mv5.string <= 7 and ms6.string='avg_rating' and mv6.string <= 2 and e.type = 'object' 
and e.subtype = 5 and e.site_guid = 1 and (obj.title like '%asdf%') OR (obj.description like '%asdf%') 

and ( (e.access_id = -2 AND e.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (e.access_id IN (2,1) OR (e.owner_guid = 5) OR ( e.access_id = 0 AND e.owner_guid = 5 ) ) and e.enabled='yes') 

and ( (m1.access_id = -2 AND m1.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m1.access_id IN (2,1) OR (m1.owner_guid = 5) OR ( m1.access_id = 0 AND m1.owner_guid = 5 ) ) and m1.enabled='yes') 

and ( (m2.access_id = -2 AND m2.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m2.access_id IN (2,1) OR (m2.owner_guid = 5) OR ( m2.access_id = 0 AND m2.owner_guid = 5 ) ) and m2.enabled='yes') 

and ( (m3.access_id = -2 AND m3.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m3.access_id IN (2,1) OR (m3.owner_guid = 5) OR ( m3.access_id = 0 AND m3.owner_guid = 5 ) ) and m3.enabled='yes') 

and ( (m4.access_id = -2 AND m4.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m4.access_id IN (2,1) OR (m4.owner_guid = 5) OR ( m4.access_id = 0 AND m4.owner_guid = 5 ) ) and m4.enabled='yes') 

and ( (m5.access_id = -2 AND m5.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m5.access_id IN (2,1) OR (m5.owner_guid = 5) OR ( m5.access_id = 0 AND m5.owner_guid = 5 ) ) and m5.enabled='yes') 

and ( (m6.access_id = -2 AND m6.owner_guid IN ( SELECT guid_one FROM test_entity_relationships WHERE relationship='friend' AND guid_two=5 )) OR (m6.access_id IN (2,1) OR (m6.owner_guid = 5) OR ( m6.access_id = 0 AND m6.owner_guid = 5 ) ) and m6.enabled='yes') 

order by obj.title limit 0, 10
从测试实体e中选择不同的e.*
在e.guid=m1.entity\u guid上连接测试\u元数据m1
在ms1.id=m1.name\u id上连接测试元素字符串ms1
在mv1.id=m1.value\u id上连接测试元素字符串mv1
在e.guid=obj.guid上连接测试对象与实体对象
在e.guid=m2.entity\u guid上加入测试元数据m2
在ms2.id=m2.name\u id上连接测试元素字符串ms2
在mv2.id=m2.value\u id上连接测试\元字符串mv2
在e.guid=m3.entity\u guid上加入测试元数据m3
在ms3.id=m3.name\u id上连接测试元素字符串ms3
在mv3.id=m3.value\u id上连接测试\元字符串mv3
在e.guid=m4.entity\u guid上加入测试元数据m4
在ms4.id=m4.name\u id上加入测试元素字符串ms4
在mv4.id=m4.value\u id上连接测试\元字符串mv4
在e.guid=m5.entity\u guid上加入测试元数据m5
在ms5.id=m5.name\u id上连接测试元素字符串ms5
在mv5.id=m5.value\u id上连接测试元素字符串mv5
在e.guid=m6.entity\u guid上加入测试元数据m6
在ms6.id=m6.name\u id上连接测试元素字符串ms6
在mv6.id=m6.value\u id上连接测试\元字符串mv6

其中ms1.string='expire_date'和mv1.string提出这样的问题通常会指出模式设计中的问题。看起来您可能正在使用该模式。

请重新格式化SQL,使其具有一些换行符,没有人希望读取这么长的行。谢谢大家告诉我,完成了。谢谢Lucero,让它更具可读性