I work with sqlite. In the settings of the application it is possible to add groups to which you can then add channels. The channels table has a TEXT type field and is equal to the id of the comma separated groups. For example, groups = 1,2,3,4,5,6 . In the group settings is displayed as the name and number of channels in the group.
SELECT g.*,COUNT(c._id) as _count FROM groups g,playlists p LEFT JOIN channels c ON p._active = 1 AND c._groups LIKE '%' || g._id || ',%' GROUP BY g._id ORDER BY g._name Everything works well, but only if there are no records in the channels table, then no groups are displayed in the settings. Help fix the sql query so that if the channels table was empty, the groups were output and the number of channels in them was zero.
CREATE TABLE IF NOT EXISTS groups (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,name TEXT)CREATE TABLE IF NOT EXISTS playlists (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,name TEXT,active INTEGER,count INTEGER)CREATE TABLE IF NOT EXISTS channels (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,name TEXT,groups TEXT,playlist_id INTEGER)- groups - 1, Movies
- groups - 2, Soaps
- groups - 3, News
- playlists - 4, My List, 1,200
- channels - 1.1 channel, '1,3'
- channels - 2, Russia, ''
- channels - 3, TNT, '1,3'
create tableinstructions to a post and attach at least one entry in each table. So it will be easier for everyone. - Sergey Gornostaev