Hallo ihr Lieben!
Leider komme ich hier einfach nicht mehr weiter und hoffe, von euch weiß jemand Rat... 8/
Gegeben sind zwei Tabellen:
Ich versuche nun einen SQL-Befehl hinzubekommen, der mir alle "feature_type"-Einträge ausgibt, die einen Bestimmten Wert in "modi_class" haben und für die KEIN Eintrag in account_feature existiert, mit einer bestimmten "acctid".
Sprich ich brauche alle Einträge dieser "modi_class", die mir dieser Query hier NICHT ausgibt:
Meine einzige Alternative ist bisher einfach alle dieser modi_class zu holen und bei jedem Schleifendurchlauf mit einem weiteren Query in der Datenbank nachzuschauen, ob kein account_feature-Eintrag existiert. Für n Einträge macht das insgsammt aber bis zu n+1 Durchläufe und das wäre sehr ungünstig.
Könntet ihr mir hier aus der Patsche helfen?
Freundliche Grüße,
der Baumkuschler
Leider komme ich hier einfach nicht mehr weiter und hoffe, von euch weiß jemand Rat... 8/
Gegeben sind zwei Tabellen:
CREATE TABLE feature_type ( # Diverse Features
featureid int(11) unsigned NOT NULL auto_increment,
modi_class varchar(50) default '', # Typ des Features
PRIMARY KEY (featureid)
) TYPE=MyISAM;
CREATE TABLE account_feature ( # Gibt an welche Features der Account besitzt
entryid int(11) unsigned NOT NULL auto_increment,
acctid int(11) NOT NULL, # Account-Id
featureid int(11) NOT NULL, # Feature-Id
PRIMARY KEY (entryid)
) TYPE=MyISAM;
featureid int(11) unsigned NOT NULL auto_increment,
modi_class varchar(50) default '', # Typ des Features
PRIMARY KEY (featureid)
) TYPE=MyISAM;
CREATE TABLE account_feature ( # Gibt an welche Features der Account besitzt
entryid int(11) unsigned NOT NULL auto_increment,
acctid int(11) NOT NULL, # Account-Id
featureid int(11) NOT NULL, # Feature-Id
PRIMARY KEY (entryid)
) TYPE=MyISAM;
Sprich ich brauche alle Einträge dieser "modi_class", die mir dieser Query hier NICHT ausgibt:
$sql = "SELECT a.featureid, a.title, a.description, a.pic, a.costs
FROM new_actor_feature_types AS a
LEFT JOIN
new_actor_features AS b
ON a.featureid = b.featureid
WHERE a.modi_class='$modi_class' AND b.acctid='$acctid'
ORDER BY a.costs ASC, a.title ASC";
FROM new_actor_feature_types AS a
LEFT JOIN
new_actor_features AS b
ON a.featureid = b.featureid
WHERE a.modi_class='$modi_class' AND b.acctid='$acctid'
ORDER BY a.costs ASC, a.title ASC";
Könntet ihr mir hier aus der Patsche helfen?
Freundliche Grüße,
der Baumkuschler
Comment