SELECT *, count(*) AS total FROM (`i_com`) RIGHT OUTER JOIN `i_all` ON `i_all`.`id_all` = `i_com`.`id_all` WHERE `category` IN ('seo', 'sites', 'ide', 'des', 'javascript_jquery', 'php_sql') AND `deleted` = 0 ORDER BY `total` desc 

#1046 - No database selected

The i_all table contains the site materials, the i_com table contains comments. Interconnected through material id (id_all). I'm trying to get a list of materials sorted by number of comments. If there are other ideas - suggest. Or it is necessary to sort on РНР?

  • 6
    >_< you are not able to translate three words? - Sh4dow

1 answer 1

In phpmyadmin, click on the database on the left and repeat the query in it .

In php, with a successful connection, you do not need to do anything. If you have not selected a database there, write

 FROM `database_name`.`i_com` 
  • Right. The fact is that with PHP this code (request) is executed without errors and in phpmyadmin with an error. But that's not the point. Why does 1 result return? Expected about 30 sorted by ... - jfjgjkslxd
  • Show how to create php when prompted? - Palmervan
  • @jfjgjkslxd because you chose a base in PHP, but apparently not in phpmyadmin. First select, then try the query. - artoodetoo