I have the following SQL statement (SQLite 3.0) which is joining two tables, the results are that I have a record per day with totals for the day, but joining it to the language table, it gives me five records per day, one for each language.
SELECT
re.day,
re.flashcardsAdded,
re.flashcardsTested,
re.flashcardsLearned,
re.totalPoints AS totalForDay,
la.language,
la.total AS totalForLanguage
FROM dpod_site_reportDays AS re
JOIN dpod_site_reportDayLanguageTotals AS la ON re.day=la.day
ORDER BY re.day DESC
However, I want only one record per day and instead of e.g. “french” being data, I want it to be a column name with the total for that language as the data for that column.
How can I change the SQL statement so that I get the language totals in the same record with appropriate field names? e.g.:
day | flashcardsAdded | flashcardsTested | flashcardsLearned | totalForDay | french | german | italian | russian | german

Here are the tables:
CREATE TABLE dpod_site_reportDayLanguageTotals(
day VARCHAR(50),
language VARCHAR(1024),
total INT(12),
extras VARCHAR(1024),
idCode VARCHAR(1024),
whenCreated VARCHAR(50),
whenChanged VARCHAR(50),
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE)
CREATE TABLE dpod_site_reportDays(
day VARCHAR(50),
flashcardsAdded INT(12),
flashcardsTested INT(12),
flashcardsLearned INT(12),
journalPoints INT(12),
readingPoints INT(12),
correctionPoints INT(12),
extrasData TEXT,
totalPoints INT(12),
extras VARCHAR(1024),
idCode VARCHAR(1024),
whenCreated VARCHAR(50),
whenChanged VARCHAR(50),
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE)
1 Answer