-1

I want to use group by with join on below data:

statistics:

| id | user_id| date|

users:

| id | name | age|

My query which doesn't return table users:

SELECT user_id, sum(time_to_sec(date)/60) as mins 
from `statistics` 
JOIN user ON users.id = statistics.user_id 
WHERE 1 and user_id=8 group BY user_id

Can anyone help?

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74

2 Answers2

3

Table name in Join is wrongly mentioned. it should be users not user as per your table definition.

Sekar Ramu
  • 343
  • 1
  • 2
  • 11
1

Typo mistake I think

JOIN user ON users.id = statistics.user_id 

Try this

JOIN users ON users.id = statistics.user_id 
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
mukund
  • 29
  • 5