我是高级查询的新手,所以我可能有一些概念上的错误,因为当数据库有超过100万条记录时,我得到了这个响应,我的查询...
ERROR 2013: Lost connection to MySQL server during query
是! 它实际上需要很长时间才能在它完成之前呕吐.
我的疑问是......
SELECT users.username,
table_1.field_abc, table_1.field_def,
table_2.field_ghi, table_2.field_jkl
FROM users
LEFT JOIN table_1 ON table_1.username = users.username
LEFT JOIN table_2 ON table_2.username = users.username
WHERE
table_1.field_abc REGEXP "(spork|yellow)" OR
table_1.field_def REGEXP "(spork|yellow)" OR
table_2.field_ghi REGEXP "(spork|yellow)" OR
table_2.field_jkl REGEXP "(spork|yellow)"
GROUP BY users.username
ORDER BY
(
( CASE WHEN table_1.field_abc LIKE "%spork%" THEN 1 ELSE 0 END ) +
( CASE WHEN table_1.field_abc LIKE "%yellow%" THEN 1 ELSE 0 …
Run Code Online (Sandbox Code Playgroud) 我可以解释我的问题,但证明它可能更容易......
如果您查看http://jsfiddle.net/XxT2B/,您会看到我的问题。我无法弄清楚如何将操作传递给函数。你会明白我的意思。
请注意,根据调用函数的内容,操作可能会有所不同。该动作可能是按时发出警报,然后是不同的内容。
这是我的代码...
function abc(action)
{
//Do a bunch of stuff first and then do the action sent to this function
alert('This function is named "abc"');
//This is the part I do not know how to do.
//The action might be an alert or something totally different so I can't just pass text
//I need to know how to execute the action passed.
action;
}
abc('alert("I like pizza")');
Run Code Online (Sandbox Code Playgroud) 我有一个表格,用户可以在其 SSL 证书副本中输入该表格。用户倾向于只输入注释而不是实际的证书。我可以使用什么正则表达式语法来确保他们输入有效的证书?
我在 StackOverflow 上发现了很多讨论解析 json 数组的线程,但我似乎不知道如何取回一些数据。这是我所拥有的...
$('#keyword_form').submit(function(e){
var gj = $.post('employee_search.php',$('#keyword_form').serialize(),function(data){
if(!data || data.status !=1 )
{
alert(data.message);
return false;
}
else
{
alert(data.message);
}
},'json');
e.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
发送给它的 json 数据看起来像这样......
{
"status":1,
"message":"Query executed in 9.946837 seconds.",
"usernames_count":{
"gjrowe":5,
"alisonrowe":4,
"bob":"1"
}
}
Run Code Online (Sandbox Code Playgroud)
正如我的函数所示,我可以执行此操作alert(data.message);
,但如何访问usernames_count
数据?
我的困惑来自于数据没有名称/标签。bob
是用户名,1
是与该用户名关联的返回计数
如果我这样做alert(usernames_count);
我会回来[object Object]
如果我这样做alert(usernames_count[0]);
我会回来undefined
我确信我应该做点什么,JSON.parse();
但我还没有做对