search

Home  >  Q&A  >  body text

How to get list of users using only one value in multiple rows - MySQL

I have a payment form. It has a column named user_id and payment_type. For each payment, users can have multiple payment types. I want to find users who have only used one payment_type in their lifetime.

Let me explain clearly with an example: Let's say I have the following data:

user_id payment_type
1   UPI
1   NB
2   UPI
2   UPI

For the above, I only want user_id 2 as output because for these two payments, it only uses 1 payment_type.

Can anyone help?

P粉214089349P粉214089349303 days ago388

reply all(1)I'll reply

  • P粉337385922
  • Cancelreply