MySQL Forums
Forum List  »  German

SQL Where In Array OR
Posted by: jomafi lpic
Date: July 18, 2011 11:27AM

Hallo,

ich sitze an einem Projekt und komme nun nicht weiter vor folgendem Problem:

Die SQL-abfrage scheitert, sobald ich "OR p.festservice_b IN (Array) OR p.festservice_c IN (Array)" verwende.

u.Dienste_budget, u.Dienste_gebiet und u.Dienste_service sind Datentypen

Es währe nett wenn einer die SQL Abfragen mal unter die Lupe nehmen könnte.
ich würde für den Support der hier geleistet wird auch bezahlen. Danke


public function getProducts($userid)
{
global $db;

$where = "WHERE NOT EXISTS (SELECT * FROM utransactions AS t WHERE t.user_id = '{$userid}' AND t.product_id = p.token)"
. "\n AND p.approved='yes'"
. "\n AND p.status='1'"
. "\n AND u.uid = '" . $userid . "'"
. "\n AND p.budget_id IN (u.Dienste_budget)"
. "\n AND p.gebiet_id IN (u.Dienste_gebiet)"
. "\n AND (p.festservice_a IN (u.Dienste_service)" //ab hier gibt´s nur Probleme
. "\n OR p.festservice_b IN (u.Dienste_service)"
. "\n OR p.festservice_c IN (u.Dienste_service))";

$sql = "SELECT p.*,"
. "\n DATE_FORMAT(p.date, '%d.%m.%Y') as created,"
. "\n DATE_FORMAT(p.festdatum, '%d.%m.%Y') as festdate,"
. "\n (TO_DAYS(NOW()) - TO_DAYS(p.festdatum)) as days,"
. "\n TO_DAYS(DATE_ADD(p.festdatum,INTERVAL -1 DAY))- TO_DAYS(NOW()) as expiry"
. "\n FROM products AS p, usersettings AS u " . $where . " ORDER BY p.date DESC";
$row = $db->fetch_all($sql);

return $row;

}

Options: ReplyQuote


Subject
Views
Written By
Posted
SQL Where In Array OR
4002
July 18, 2011 11:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.