Trying to create a tag cloud with tips from https://www.quora.com/What-is-the-easiest-way-to-create-a-tag-cloud-from-a-MySQL-column
I'm creating a new table within a database. Database has table named 'tracks' Table has column called 'tag' 'Tag' fields are populated with tags separated by commas ie tag01,tag02,tag03, etc
I am trying to create a new table which
I have run the following
CREATE TABLE counter (
id int unsigned NOT NULL AUTO_INCREMENT,
primary key (id)
);
----
delimiter //
CREATE PROCEDURE populate_counter()
BEGIN
SET @i = 0;
SET @n = (select max(LENGTH(tag) - LENGTH(REPLACE(tag, ' ', ''))+1) from tracks);
WHILE @i<@n DO
INSERT INTO counter (id) VALUES (NULL);
SET @i = @i + 1;
END WHILE;
END
//
delimiter ;
----
That part seems to have gone OK. I then try and run the procedure
call populate_counter()
----
select
word,
count(*) as freq
from (
select
case
when id <= LENGTH(tag) - LENGTH(REPLACE(tag, ' ', ''))+1 then SUBSTRING_INDEX(SUBSTRING_INDEX(tag, ' ', id), ' ', -1)
else ''
end as word
from tracks, counter
) t
where
0 < LENGTH(word)
group by word
I get this:
MySQL #1052 - Column 'id' in field list is ambiguous.
Not sure how to proceed from there.
Any advice most welcome!
Apache/2.4.10 (Debian) Database client version: libmysql - 5.5.57 PHP extension: mysqli
Thanks