![]() |
![]() |
|
![]() |
![]() |
|
Programmierung Rat & Tat für Programmierer |
|
Themen-Optionen | Ansicht |
![]() |
#1 |
Elite
![]() |
![]() Hallo,
ich arbeite an einem Teil eines Umfrageprogramms, das wir hier mit PHP und SQL (über en ADODB-wrapper, ich hab hier MySQL drauf) entwickeln. Eigentlich war mein Teil schon fertig, allerdings wurde jetzt das Datenbankdesign etwas geändert, weshalb ich ein SQL neu schreiben muss. Nun komme ich einfach nicht darauf, wie ich dieses eine Qerry machen muss. *grummel* Es geht dabei um folgende Tabellen: Code:
CREATE TABLE poTAnswer ( nAnswerNR int(11) NOT NULL auto_increment, nSortOrder float NOT NULL default '0', nQuestionNR int(11) NOT NULL default '0', nTypeNR int(11) NOT NULL default '0', nAnswer float default NULL, sAnswer varchar(250) NOT NULL default '', dCreate datetime NOT NULL default '0000-00-00 00:00:00', nUserNRCreator int(11) NOT NULL default '1', PRIMARY KEY (nAnswerNR), UNIQUE nSortOrder(nQuestionNR,nSortOrder), FOREIGN KEY (nQuestionNR) REFERENCES poTQuestion ON DELETE CASCADE, FOREIGN KEY (nTypeNR) REFERENCES poTType, KEY nUserNRCreator (nUserNRCreator) ) TYPE=MyISAM AUTO_INCREMENT=1 /* RELATIONS FOR TABLE poTAnswer: nAnswerNRBefore poTAnswer -> nAnswerNR nQuestionNR poTQuestion -> nQuestionNR nTypeNR poTType -> nTypeNR */; # -------------------------------------------------------- DROP TABLE IF EXISTS poTQuestion; CREATE TABLE poTQuestion ( nQuestionNR int(11) NOT NULL auto_increment, nPollNR int(11) NOT NULL default '0', nTypeNR int(11), nSortOrder float NOT NULL default '0', sName varchar(8), sQuestion text NOT NULL default '', dCreate datetime NOT NULL default '0000-00-00 00:00:00', nUserNRCreator int(11) NOT NULL default '1', nCategoryNR int(11) NULL default NULL, PRIMARY KEY (nQuestionNR), FOREIGN KEY nPollNR (nPollNR) REFERENCES poTPoll, FOREIGN KEY (nCategoryNR) REFERENCES poTCategory, KEY nSortOrder (nPollNR,nSortOrder), KEY nUserNRCreator (nUserNRCreator) ) TYPE=MyISAM AUTO_INCREMENT=1 /* RELATIONS FOR TABLE poTQuestion: nPollNR poTPoll -> nPollNR nQuestionNRBefore poTQuestion -> nQuestionNR */; # -------------------------------------------------------- CREATE TABLE poTUserAnswer ( nUserAnswerNR int(11) NOT NULL auto_increment, nQuestionNR int(11) NOT NULL default '0', nCaseNR int(11) NOT NULL default '0', nAnswerNR int(11) default NULL, sAttribute text default NULL, nAttribute float default NULL, PRIMARY KEY (nUserAnswerNR), FOREIGN KEY (nQuestionNR) REFERENCES poTQuestion, FOREIGN KEY (nCaseNR) REFERENCES poTCase, FOREIGN KEY (nAnswerNR) REFERENCES poTAnswer ) TYPE=MyISAM AUTO_INCREMENT=1 ; /* RELATIONS FOR TABLE poTUserAnswer: nAnswerNR poTAnswer -> nAnswerNR nCaseNR poTCase -> nCaseNR */; So, ich hoffe das war halbwegs verständlich. Irgendwie hab ich das mit den anderen joins verlernt, und ich kann nur noch left inenr joins, da ich eigentlich fast immer nur diese brauch ![]() Viel, vielen Dank schon mal für alle, die sich den Text bis hier her durchgeschaut haben und mir evtl. Helfen können. Nestrus
____________________________________
"reden 2 unsinn im wcm forum, meint der dritte is eh offtopic" (Gifty am 14. Apr 2002 um 22:47 in " WCM Rat & Tat Forum > Meinung > Guru, e-Zitate & Off Topic > Kommt ein Mann zum Arzt...") |
![]() |
![]() |
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|