jeudi 8 octobre 2015

(No such column).. But, it's there

Here's my tables:

CREATE TABLE IF NOT EXISTS message_threads (
    thread_id integer primary key autoincrement NOT NULL,
    user_id integer NOT NULL, 
    last_checked timestamp NOT NULL DEFAULT '0',
    last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
)

CREATE TABLE IF NOT EXISTS messages (
    message_id integer primary key autoincrement NOT NULL,
    thread_id integer NOT NULL,message_type integer NOT NULL DEFAULT '0',
    message_content varchar(500) NOT NULL,
    message_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    sent integer NOT NULL DEFAULT '0'
);

Here's the error I'm getting:

Could not prepare statement (1 no such column: m.message_date)

Here's the query that I'm using (This query works in MySQL, as I tested it in PHPMyAdmin with a dummy table)

SELECT * FROM messages m, message_threads t
    WHERE m.thread_id = t.thread_id
    ORDER BY t.last_updated, t.thread_id, m.message_date;

I'm using WebSQL (which I think is SQLite)

Aucun commentaire:

Enregistrer un commentaire