0

I have tried this query in phpmyAdmin

SELECT COUNT(*) 
FROM meal_participants_user 
INNER JOIN user ON meal_participants_user.userId = user.id 
ORDER BY meal_participants_user.mealId ASC;

And got in phpMyAdmin the answer 6,

But when I ran this in a nodeJs app,

I got this answer

|count(*)|
| 8      |

What causes this problem and how can I fix it?

note: all data are not real Tables

User:

User

meal_participants_user

meal_participants_user

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Based on your table data, which one is the correct result? –  May 09 '22 at 20:39
  • `ORDER BY` makes no sense in this query. There's only one row returned, there's nothing to order. – Barmar May 09 '22 at 20:54
  • I don't see any way that you can get a result of `8` with the data you show. If `user.id` is the primary key, the result can't be more than the number of rows in `meal_participants_user`. – Barmar May 09 '22 at 20:56

0 Answers0