Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql select and count left join

select
  t.Topic,
  t.Title,
  count(distinct s.starID) as StarCount,
  count(distinct m.User) as UserCount,
  count(distinct m.messageID) as MessageCount
from
  Topics t
  left join Messages m ON m.Topic = t.Topic
  left join Stars_Given s ON s.Topic = t.Topic
group by
  t.Topic,
  t.Title
Comment

PREVIOUS NEXT
Code Example
Sql :: create table sqlite 
Sql :: select all_source oracle 
Sql :: ubuntu reset mysql root password 
Sql :: oracle plsql sleep 
Sql :: postgres set default schema 
Sql :: mysql grant grant option 
Sql :: postgresql how to show table names 
Sql :: delete record mysql query 
Sql :: what is the default password for sql server sa 
Sql :: mysql update row 
Sql :: how to fetch first 5 characters in sql 
Sql :: how to sort names in alphabetical order in sql 
Sql :: get name of day in sql 
Sql :: oracle auto increment primary key 
Sql :: mysql set id auto increment 
Sql :: change column name sql server management studio 
Sql :: ubuntu connect to mssql database 
Sql :: postgres statistics 
Sql :: oracle insert or update 
Sql :: mysql add column after another 
Sql :: postgres list all triggers 
Sql :: sql compare two tables for differences 
Sql :: oracle nextval insert 
Sql :: pad zero sql server 
Sql :: Mysql Create table with foreign keys. 
Sql :: sql first 
Sql :: how to calculate number of days between two dates excluding weekends in oracle 
Sql :: import mysql dump command line 
Sql :: sql select duplicates based on two columns 
Sql :: how to drop function in sql 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =