Query unter Windows OK, unter Linux Error

C

cmg

Mitglied
Hi,

ich habe folgende Abfrage:
PHP:
$sql = "SELECT MAX(MU), Date FROM(SELECT COUNT(UserMeeting.UserID) AS 'MU', Date.Date, Date.Avail FROM UserMeeting, Meeting, User, Date WHERE Meeting.MeetingID = UserMeeting.MeetingID AND UserMeeting.UserID = User.UserID AND User.UserID = Date.UserID AND Date.Avail = '1' AND Date.Date >= NOW() AND Meeting.MeetingID = '$meetingid' GROUP BY Date.Date) MAXU";

 $result = mysql_query($sql);
Unter Windows bekomm ich das gewünschte Ergebnis, unter Linux (mit den identischen Datei) bekomm ich $result == false.

Ich habe vorhin den selben Fehler schon mal gehabt und da lag es daran, dass ich statt dem Tabellennamen "Date" "DATE" schrieb.
Ich fürchte irgendwie sowas Spitzfindiges ist es hier auch.

Anbei die Sturktur wie ich sie in MySQL reingehauen habe:

PHP:
CREATE DATABASE Calendar;

use Calendar;

CREATE TABLE IF NOT EXISTS User 
(
  UserID int (5) NOT NULL AUTO_INCREMENT,
  UserName CHAR(30) NOT NULL,
  PRIMARY KEY (UserID)
) ENGINE=InnoDB;


CREATE TABLE IF NOT EXISTS Meeting
(
  MeetingID int (5) NOT NULL AUTO_INCREMENT,
  MeetingName CHAR(30) NOT NULL,
  MeetingDate DATE NOT NULL,
  PRIMARY KEY (MeetingID)
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS Date
(
  DateID int (5) NOT NULL AUTO_INCREMENT,
  Date DATE NOT NULL,
  UserID int (5) NOT NULL,
  Avail BOOL NOT NULL,
  PRIMARY KEY (DateID),
  FOREIGN KEY(UserID) REFERENCES User(UserID) ON DELETE CASCADE
) ENGINE=InnoDB;


CREATE TABLE IF NOT EXISTS UserMeeting
(
  UserID int (5) NOT NULL,
  MeetingID int (5) NOT NULL,
  FOREIGN KEY(UserID) REFERENCES User(UserID) ON DELETE CASCADE,  
  FOREIGN KEY(MeetingID) REFERENCES Meeting(MeetingID) ON DELETE CASCADE
) ENGINE=InnoDB;
 
1140: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause bekomme ich da... puh...

Okay, mit MAXU GROUP BY Date am Ende gehts. Danke: )
 
Zuletzt bearbeitet:
dann füge doch ein group by hinzu ;)

Code:
SELECT MAX(MU), Date FROM(
   SELECT COUNT(UserMeeting.UserID) AS 'MU', Date.Date, Date.Avail
   FROM UserMeeting, Meeting, User, Date
   WHERE Meeting.MeetingID = UserMeeting.MeetingID
   AND UserMeeting.UserID = User.UserID
   AND User.UserID = Date.UserID
   AND Date.Avail = '1'
   AND Date.Date >= NOW()
   AND Meeting.MeetingID = '$meetingid'
   GROUP BY Date.Date
) MAXU <<< dort fehlt eins
 

Ähnliche Themen

Zugriff Ubuntu 16.04. auf Freigabe 18.04. LTS nicht möglich

Akonadi startet nicht mehr

Samba 4 Gast Zugang unter Ubuntu funktioniert nicht

Mit bash mysql in Schleife abfragen

Windows clients können nicht mehr auf lange laufendes System zugreifen

Zurück
Oben