内部加入Joomla不工作

时间:2013-04-15 16:17:15

标签: joomla2.5 inner-join

有什么不对?

$db = JFactory::getDbo();
$query = $db->getQuery(true);        
$query = "SELECT jml.*,grkt.*,grk.*,jml.*"
."\n , FROM #__egerak_subutama AS grk"
."\n , inner join #__users AS jml ON jml.username = grk.username"
."\n , inner join #__egerak_kenyataan AS grkt ON grkt.kategori = grk.kategori"  
."\n , where actdate <= '$currYear- ". sprintf("%02d", $currMonth) . " - " . sprintf("%02d", $currDay). " '"
."\n , AND enddate >= '$currYear-". sprintf("%02d", $currMonth) . "-" . sprintf("%02d", $currDay). "'"
."\n , AND kodunit LIKE '%$ppdlms%'";

您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'FROM lpk_egerak_subutama AS grk附近使用正确的语法,内部联接lpk_users AS jml ON jml.username ='第2行SQL = SELECT jml。,grkt。,grk。,jml。,FROM lpk_egerak_subutama AS grk,内部联接lpk_users AS jml ON jml.username = grk.username,内部联接lpk_egerak_kenyataan AS grkt ON grkt.kategori = grk.kategori,其中actdate&lt; ='2013- 04 - 15',AND enddate&gt; ='2013-04-15',和kodunit LIKE'%%'

1 个答案:

答案 0 :(得分:0)

$db = JFactory::getDbo();
$query = $db->getQuery(true);        
$query = "SELECT jml.*,grkt.*,grk.*,jml.*"
."\n FROM #__egerak_subutama AS grk"
."\n inner join #__users AS jml ON jml.username = grk.username"
."\n inner join #__egerak_kenyataan AS grkt ON grkt.kategori = grk.kategori"  
."\n where actdate <= '$currYear- ". sprintf("%02d", $currMonth) . " - " . sprintf("%02d", $currDay). " '"
."\n AND enddate >= '$currYear-". sprintf("%02d", $currMonth) . "-" . sprintf("%02d", $currDay). "'"
."\n AND kodunit LIKE '%$ppdlms%'";

从该行的开头删除所有逗号。您收到错误是因为逗号使mysql期望另一个项目不是from关键字。