mysql need get count of dependencies of other table

Scorpioniz

have 2 tables:

`contactslistrelations`

(`id`, `contactid`, `contactlistid`)
(1, 1, 1),
(2, 2, 1),
(3, 3, 1),
(4, 4, 1),
(5, 5, 1),
(6, 6, 1),

and another one:

`contacts`

(`id`, `name`, `surname`, `email`, `unsubscribed`)
(1, "name1", "surname1", "email1", "0"),
(2, "name1", "surname2", "email1", "0"),
(3, "name1", "surname3", "email1", "0"),
(4, "name1", "surname4", "email1", "1"),
(5, "name1", "surname5", "email1", "0"),
(6, "name1", "surname6", "email1", "0"),

And I need to get count from contactlistrelations table of contacts which is not unsubscribed in contacts table

Kasper Franz

You can use join like this, which should return the number of people on each contactList which isn't unsubscribed

Select contactlistrelations .contactlistid,count(*) AS count 
  FROM contactlistrelations 
  JOIN contacts on contacts.id = contactlistrelations.contactid 
  WHERE contacts.unsubscribed = 0
  GROUP BY contactlistrelations.contactlistid

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Join other table to get count

From Dev

Mysql Count of rows not referenced in other table

From Dev

Mysql Count of rows not referenced in other table

From Dev

PHP get a count of duplicate values in a MySQL table

From Dev

mySQL count and get maximum from table

From Dev

MySql get count(*) with a join from a table

From Dev

I need a MySQL query for find the total count from a table

From Dev

Get random images with other table in mysql

From Dev

Get random images with other table in mysql

From Dev

MySQL Query - SELECT row count from other table

From Dev

Mysql for a given group type get count and sum from other tables

From Dev

MySQL: Get last update id from a table to insert it in an other table

From Dev

MySQL: Get last update id from a table to insert it in an other table

From Dev

MySQL: Count in other tables

From Dev

Need count of transactional table based on other tables including zeros where there are no matches

From Dev

count all items in table mysql plus get record

From Dev

MySQL query to get count of column name from a table of a database?

From Dev

MySQL how to get correct count of all desired fields in table

From Dev

How to get count of a particular item from table using mysql

From Dev

I want to get multiple count from same table in mysql

From Dev

Mysql - How to get all records being in other column in the same table

From Dev

How to get an average from a table that was originated by other 2 tables in MySQL?

From Dev

mySQL count table efficiently

From Dev

MySQL count on joined table

From Dev

mySQL count table efficiently

From Dev

Need to get other value on timer

From Dev

mysql not exist in other table

From Dev

Get the count of each table

From Dev

Need to set difference of two dates fields in other column inside same table using single MySQL query

Related Related

  1. 1

    Join other table to get count

  2. 2

    Mysql Count of rows not referenced in other table

  3. 3

    Mysql Count of rows not referenced in other table

  4. 4

    PHP get a count of duplicate values in a MySQL table

  5. 5

    mySQL count and get maximum from table

  6. 6

    MySql get count(*) with a join from a table

  7. 7

    I need a MySQL query for find the total count from a table

  8. 8

    Get random images with other table in mysql

  9. 9

    Get random images with other table in mysql

  10. 10

    MySQL Query - SELECT row count from other table

  11. 11

    Mysql for a given group type get count and sum from other tables

  12. 12

    MySQL: Get last update id from a table to insert it in an other table

  13. 13

    MySQL: Get last update id from a table to insert it in an other table

  14. 14

    MySQL: Count in other tables

  15. 15

    Need count of transactional table based on other tables including zeros where there are no matches

  16. 16

    count all items in table mysql plus get record

  17. 17

    MySQL query to get count of column name from a table of a database?

  18. 18

    MySQL how to get correct count of all desired fields in table

  19. 19

    How to get count of a particular item from table using mysql

  20. 20

    I want to get multiple count from same table in mysql

  21. 21

    Mysql - How to get all records being in other column in the same table

  22. 22

    How to get an average from a table that was originated by other 2 tables in MySQL?

  23. 23

    mySQL count table efficiently

  24. 24

    MySQL count on joined table

  25. 25

    mySQL count table efficiently

  26. 26

    Need to get other value on timer

  27. 27

    mysql not exist in other table

  28. 28

    Get the count of each table

  29. 29

    Need to set difference of two dates fields in other column inside same table using single MySQL query

HotTag

Archive