#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    12
    Rep Power
    0
    I want to execute a composed request, ie :

    $result = mysql_query("SELECT NomDem FROM reversation WHERE datrep= (SELECT MAX(datrep) FROM Représentation WHERE DatRep<='31-12-99')");

    but PHP doesn't seems to like the second SELECT...

    Any solution ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    32
    Rep Power
    15
    Yeah.. unfortunately, you just used subselects.. which mysql doesn't support.. =) use joins instead..

    $result = mysql_query("SELECT
    reversation.NomDem,
    reversation.datrep revdat,
    Représentation.MAX(datrep) repmax
    FROM
    reversation,
    Représentation
    WHERE
    revdat = repmax
    AND
    repmax <= '31-12-99')");

    Hmm.. i dunno if i got it correct the first time round, correct me if i'm wrong =)

    good luck

    scoobydoo

    [This message has been edited by scoobydoo (edited June 18, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    12
    Rep Power
    0
    Thanks for the answer.
    Too bad MySQL doesn't support it
    I will use joins as you say...

    BTW, don't you know how to use a join with a GROUP BY in the same request :

    ie, here is the sql request which doesn't works :

    $select = mysql_query("SELECT MAX(date),numeropost,auteur,icone,forumcont.titre FROM thread,forumcont GROUP BY numeropost HAVING forumcont.numeropost=thread.numeropost ORDER BY date DESC");
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    12
    Rep Power
    0
    up !
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    London
    Posts
    46
    Rep Power
    15
    I believe that your HAVING statement should come before the GROUP BY statement.

    Give it a try.

    Kelvin
    __________________

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by joce:
    Thanks for the answer.
    Too bad MySQL doesn't support it
    I will use joins as you say...

    BTW, don't you know how to use a join with a GROUP BY in the same request :

    ie, here is the sql request which doesn't works :

    $select = mysql_query("SELECT MAX(date),numeropost,auteur,icone,forumcont.titre FROM thread,forumcont GROUP BY numeropost HAVING forumcont.numeropost=thread.numeropost ORDER BY date DESC");
    [/quote]

Similar Threads

  1. problem: asp files, from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: November 26th, 2003, 04:16 AM
  2. Executing Multiple SQL Queries (MySQL)
    By AoErat in forum PHP Development
    Replies: 1
    Last Post: October 21st, 2003, 03:08 AM
  3. Can't connect to MySQL server remotely
    By bper in forum MySQL Help
    Replies: 2
    Last Post: October 2nd, 2003, 03:09 PM
  4. Replies: 3
    Last Post: July 10th, 2003, 08:47 PM
  5. Error 1045 & MySQL Configuration
    By ksp in forum MySQL Help
    Replies: 10
    Last Post: June 30th, 2003, 08:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo