2021年4月22日星期四

How to select only records that contain a unique value in a certain column

I have a table (tbl_payments) with 4 columns like this:

+------------+------------+-------+------------+    | User_id    | Name       | Status|  Payment No|  +------------+------------+-------+------------+      

Now imagine records like this.

1| Luigi | Active | 1  1| Luigi | Active | 2  1| Luigi | Active | 3  2| Peach | Active | 1  2| Peach | Active | 2  2| Peach | Paid   | 3  3| Bowser| Active | 1  3| Bowser| Active | 2  3| Bowser| OFF    | 3  

I need a query that returns only users that have one unique status, for example, our query would return:

1| Luigi | Active   

I have tried a subquery without success, any clue would be amazing, thank you guys in advance.

https://stackoverflow.com/questions/67222985/how-to-select-only-records-that-contain-a-unique-value-in-a-certain-column April 23, 2021 at 09:55AM

没有评论:

发表评论