there are 3 tables
CREATE TABLE IF NOT EXISTS `category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10; CREATE TABLE IF NOT EXISTS `category_typeadverts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_category` int(11) NOT NULL, `id_type` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; CREATE TABLE IF NOT EXISTS `type_adverts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type_title` varchar(64) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; how to create a query in this way, or how to do it with the help of a handler to select all records from the type_adverts table and select id and title for each record (one element can contain several rows from the category table) from the category table, while the two tables are related in the third category_typeadverts