in reply to DBI problem on fetchrow

This query doesn't look right to me: "SELECT MAX(M.Score) FROM Regions M". Specifically that stray "M" on the end doesn't seem like proper syntax. Since you're specifying "M.Score" as what you want, I'm guessing "M" is a table name. Maybe you want a comma between "Regions" and "M"? It really doesn't die when you try to prepare or execute that?

Update: Oh yes, I have seen table aliases before, thanks for the many reminders. Since I hardly use them myself, I'm not used to seeing them. Sorry about the confusion.

Replies are listed 'Best First'.
Re^2: DBI problem on fetchrow
by jZed (Prior) on Nov 15, 2007 at 17:36 UTC
    That part of what the OP is doing is ok. "M" is being used as a table alias. SQL syntax supports table aliases either with or without the optional keyword "AS", so these two are the same, they both let you refer to "Regions" as "M":
    SELECT M.foo FROM Regions AS M; SELECT M.foo FROM Regions M;

      As a matter of style I would recomend using the "as" consistently. It reads better.

      BTW, "Regions as M"? Maybe there is a reason to use M for the Regions table, but I would expect R or (in case the table was used several times in the query) something like R_old, R_new, R1, R2, .... In either case I do not see why would you use an alias in a query that only includes one table. I guess a matter of style again :-)

        I agree. I always use AS.
Re^2: DBI problem on fetchrow
by erroneousBollock (Curate) on Nov 15, 2007 at 17:36 UTC
    That's called a "table alias" in SQL and is perfectly valid.

    You may like to read the SQL99 standard.

    -David

Re^2: DBI problem on fetchrow
by moritz (Cardinal) on Nov 15, 2007 at 17:42 UTC
    The SQL works fine with MySQL, the M is a table alias, the syntax is ... FROM table1 alias1, table2 alias2, ... with the alias$n being optional