left join with where in right table

Jhonny Pamponet

I have this Join: Table mmp_user 151 users Table MMP_MMPUBLISH_LOG URL's access

    select user.name as 'Usuário',count(log.referer) as 'Número de Acessos'
from mmp_user user
left JOIN MMP_MMPUBLISH_LOG log on (user.id=log.user_id)
where log.event_date between '2015-08-01' and '2015-08-08'
group by user.id
order by count(log.referer) desc

expected outcome: 151 lines obtained results: 11 lines

Help me please

Mattia Caputo

try with this

SELECT u.name as 'Usuário',count(log.referer) as 'Número de Acessos'
FROM mmp_user u
LEFT JOIN (
    SELECT user_id, referer
    FROM MMP_MMPUBLISH_LOG
    WHERE event_date BETWEEN '2015-08-01' AND '2015-08-08'
) log ON u.id=log.user_id
group by u.id
order by count(log.referer) desc

ps. next time don't use 'user', it's not clear

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Laravel Left join add where clause to right table

From Dev

Laravel Left join add where clause to right table

From Dev

Left join with on a limited right table

From Dev

Left join with where clause for right table (Must return NULL from right) - Oracle

From Dev

Left join with where clause for right table (Must return NULL from right) - Oracle

From Dev

Left Join with Count and Where Clause on right side

From Dev

How do I do a LEFT JOIN in MySQL, where I have missing key values in the RIGHT table?

From Dev

MySQL LEFT JOIN is returning just one row with a where condition on the right table

From Dev

What is the "left" and "right" table in an intermediate SQL Join?

From Dev

Perform right outer join with a condition for left table

From Dev

Mysql left join with condition in right table

From Dev

SQLite left join with two conditions in right table

From Dev

What is the "left" and "right" table in an intermediate SQL Join?

From Dev

Mysql left join with condition in right table

From Dev

LEFT JOIN missing values from the right table

From Dev

SQL Left Join - Multiple Rows in Right Table

From Dev

Example where a right join cannot be converted to left join?

From Dev

How to join tables including all ids from left table but only showing information from the right table given certain where clause

From Dev

JOIN WHERE Right Table Have No Entries

From Dev

Where clause for only one table in a left join

From Dev

Mysql LEFT JOIN same table with WHERE condition

From Dev

Mysql LEFT JOIN same table with WHERE condition

From Dev

LEFT Join PSQL where the AND parameter is on another table

From Dev

Join two tables on date, where date from right table is greater than date from left table but less than the next greatest date in right table

From Dev

msyql union of left and right join plus where conidtion not working

From Dev

MySQL join tables where all left records are in right

From Dev

What is the proper syntax for multiple left join and where condition on the left table?

From Dev

mySQL LEFT JOIN and COUNT number of occurrences in right hand table

From Dev

left join two tables on a non-unique column in right table

Related Related

  1. 1

    Laravel Left join add where clause to right table

  2. 2

    Laravel Left join add where clause to right table

  3. 3

    Left join with on a limited right table

  4. 4

    Left join with where clause for right table (Must return NULL from right) - Oracle

  5. 5

    Left join with where clause for right table (Must return NULL from right) - Oracle

  6. 6

    Left Join with Count and Where Clause on right side

  7. 7

    How do I do a LEFT JOIN in MySQL, where I have missing key values in the RIGHT table?

  8. 8

    MySQL LEFT JOIN is returning just one row with a where condition on the right table

  9. 9

    What is the "left" and "right" table in an intermediate SQL Join?

  10. 10

    Perform right outer join with a condition for left table

  11. 11

    Mysql left join with condition in right table

  12. 12

    SQLite left join with two conditions in right table

  13. 13

    What is the "left" and "right" table in an intermediate SQL Join?

  14. 14

    Mysql left join with condition in right table

  15. 15

    LEFT JOIN missing values from the right table

  16. 16

    SQL Left Join - Multiple Rows in Right Table

  17. 17

    Example where a right join cannot be converted to left join?

  18. 18

    How to join tables including all ids from left table but only showing information from the right table given certain where clause

  19. 19

    JOIN WHERE Right Table Have No Entries

  20. 20

    Where clause for only one table in a left join

  21. 21

    Mysql LEFT JOIN same table with WHERE condition

  22. 22

    Mysql LEFT JOIN same table with WHERE condition

  23. 23

    LEFT Join PSQL where the AND parameter is on another table

  24. 24

    Join two tables on date, where date from right table is greater than date from left table but less than the next greatest date in right table

  25. 25

    msyql union of left and right join plus where conidtion not working

  26. 26

    MySQL join tables where all left records are in right

  27. 27

    What is the proper syntax for multiple left join and where condition on the left table?

  28. 28

    mySQL LEFT JOIN and COUNT number of occurrences in right hand table

  29. 29

    left join two tables on a non-unique column in right table

HotTag

Archive