I can't seem to get my cast to work correctly
Below is my sample code
CREATE TABLE test (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
refname varchar(40) NOT NULL,
parent_id int UNSIGNED DEFAULT NULL,
is_active int UNSIGNED DEFAULT 1,
PRIMARY KEY (id),
FOREIGN KEY (parent_id) REFERENCES test (id)
ON DELETE CASCADE ON UPDATE CASCADE
);
SELECT id, refname, parent_id, 1 AS depth, CAST(refname as LONGTEXT)
FROM test
WHERE parent_id IS NULL
Whenever i try to run this query it gives me
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LONGTEXT) FROM test WHERE parent_id IS NULL' at line 1
I have gone though several resources to try and identify what is wrong here, But I cannot seem to figure this out.
Does anyone have any ideas?
Thanks all :)