问题解决了!
mysql_set_charset('utf8',$conn);
如果我直接在服务器上运行它,以下mysql查询工作正常。如果我试图通过PHP运行这个我没有错误也没有结果......有什么建议吗?
查询
Select Distinct
users.last_name,
accounts.name,
Max(Distinct tasks.date_entered) as credate,
accounts_cstm.kategorie_c,
accounts_cstm.geschaeftsfeld_c as Geschäftsfeld,
Count(tasks_cstm.betreff_c),
tasks_cstm.nz_c,
tasks_cstm.betreff_c
From
tasks Left Join users On tasks.created_by = users.id
Inner Join accounts On tasks.parent_id = accounts.id
Left Join tasks_cstm On tasks.id = tasks_cstm.id_c
Inner Join accounts_cstm On accounts.id = accounts_cstm.id_c
Where tasks_cstm.betreff_c In ('Call', 'Angebot', 'Mail')
And tasks.deleted = 0
Group By
accounts.name, tasks_cstm.betreff_c
Having
(tasks_cstm.betreff_c = 'Call') Or
(tasks_cstm.betreff_c = 'Angebot') Or
(tasks_cstm.betreff_c = 'Mail')
Order By
credate Desc;
PHP代码
$conn = mysql_connect($dbserver, $dbuser, $dbpw);
if (!$conn || !mysql_select_db('sugar', $conn)) {
echo "con error"; }
else {
$query = "[query from above]";
$push = mysql_query($query);
if (!$push) {
echo "query error"; }
else {
echo "query ok";
mysql_free_result($push); }
mysql_close($conn); }
任何简单的查询都可以正常工作......
由于
答案 0 :(得分:0)
问题解决了。
错过了“AsGeschäftsfeld”......
mysql_set_charset('utf8',$conn);
答案 1 :(得分:0)
您可以使用
$row = mysql_fetch_assoc($query);
print_r($row);