Wednesday, 17 November 2010

phpMyAdmin shown bad data for same column names

(phpMyAdmin 2.2.3)

I have run the SQL with some joins and as the result I had two columns named name:
SELECT
    competitor.*,
    club.name,
    class.name
FROM ...

As a result I got two columns with same name and same values (both had class.name values). This was not the case when I tried to run the same SQL on database directly.

The solution is simple - just set some different aliases for those columns:
SELECT
    competitor.*,
    club.name AS club_name,
    class.name AS class_name
FROM ...

No comments:

Popular Posts