Hallo zusammen,
leider fehlt mir die Zeit mich wieder mit MySQL zu beschäftigen.
Ich möchte untenstehende Datenbankabfrage zu einer Abfrage vereinen. Sicherlich mit einem JOIN machbar. Wichtig hierbei ist, dass bei beiden Abfragen nach dem Datum sortiert wird, wobei bei Abfrage 1 das Datum "created" und bei Abfrage 2 "date" heißt. Im Array sollte dann alles "created" heißen. Also date soll auch zu created werden. Das ganze ist MySQL ,PHP5.
Die Abfragen hängen nicht voneinander ab. Das eine sind Beiträge, das andere die Infos aus Weblinks. Das Array wird danach entsprechend verwertet.
Bei weiteren Fragen gerne per PM.
Ich möchte Euch bitten den Code mir direkt per Email zu schicken, welche Ihr ebenfalls per PM bekommt. Für eine funktionierende Abfrage zahle ich 50 €
PHP-Code:
$query = 'SELECT a.*, u.id, u.name,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
' FROM #__content AS a' .
($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
' LEFT JOIN #__users AS u ON u.id = a.created_by' .
' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE '. $where .' AND s.id > 0' .
($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
($catid ? $catCondition : '').
($secid ? $secCondition : '').
"\n AND ((TO_DAYS('" . date( 'Y-m-d', time()+$tzoffset*60*60 ) . "') ) )".
($show_front == '0' ? ' AND f.content_id IS NULL ' : '').
' AND s.published = 1' .
' AND cc.published = 1' .
' ORDER BY a.created DESC';
$db->setQuery($query, 0, $count);
$rows1 = $db->loadObjectList();
$query2 = 'SELECT a.id, a.title, a.url, a.date AS created, a.description, a.catid' .
' FROM #__weblinks AS a' .
' LEFT JOIN #__categories AS cc ON cc.id = a.catid' .
' WHERE ( a.published = 1 AND a.approved = 1 )' .
( $catid ? "\n AND ( a.catid IN ( $catid ) )" : '' ).
' AND cc.published = 1' .
' ORDER BY a.date DESC';
$db->setQuery($query2,0,$count);
$list = $db->loadObjectList();