select
c.std_date,c.conf_link,c.conf_link as
link,c.conf_id,c.url_id,c.entry_source,c.data_source,c.title,c.conf_domain,
c.descrip, c.std_loc, c.std_practices,c.region, co.company_id,co.company,co.home_url
from
conferences c, companies co
where c.org_id= co.company_id and c.org_id in
(12,47,173,120,102,83,95,172,200,78,199,523,134,123,30,185,103,202,
159,133,178,49,161,146,17,212,136,43,107,147,142,3, 205,171,177,443,175,74,156,41,42,128,5,7,62,37,195,68,89,8,39,85,126,36,24,206,208,201,150,152,168,59,97,28,11,116,140,98,117,51,174,93,192,50,617,176,101,194,527,61,179,170,145,40,92,257,149,48,88,486,20,111,106,203,19,31,163,81,25,38,623,628,642,643,644,645,647,677,711,712,713,6173,6174,6176,6177,6184,6185,6186,6189,6191,6207,6210,6211,6212,6214,6215,6217,6218,6219,6222,6223,6224,6294,6297,6298,6300,6301,6302,7468,7469,7471,7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7489,7490,7491,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,7503,7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,7522,7523,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537,7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,7550,7551,7552,7553,7554,7555,7556,7557,7558,7559,7560,7562,7566)
and conf_id !='' and (region !='123' and region not like 'webinar%') and std_date >= '2013-04-17' and std_date <= '2013-04-24' and (data_source like 'E%' OR data_source like 'A%') and region != '' and org !='' and title not like '%groupcast%' and relevance >= 0 order by std_date desc limit 3500
答案 0 :(得分:2)
这应该是你需要的。您不必手动键入id
where c.org_id= co.company_id and c.org_id in (Select id from Conferences)
答案 1 :(得分:1)
嗯,这很容易:
首先看一下“解释......”
看,导致行太多的原因
重新制定以获得更好的结果。
尽管有日期范围,我看不到真正的限制。 std_date是datetime-field吗?然后添加时间00:00:00可以帮助(如果有任何索引)。我也更喜欢内联,
来自会议c
内部联盟公司co在c.org_id = co.company_id
但这不会提高速度。
“喜欢......”,特别是“不喜欢......”是嫌疑人。
如果只有一个候选者(如果该字段上有任何索引的索引用法),那么像E%或类似A%这样的条件要快得多 - 然后对两个单个查询进行UNION。
“data_source like”可以从text-index获得一些帮助。