Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distinct() method #235

Closed
wants to merge 1 commit into from
Closed

Add distinct() method #235

wants to merge 1 commit into from

Conversation

sargunv
Copy link

@sargunv sargunv commented May 3, 2015

User can do $db->distinct()->select(...) to do a distinct selection (add DISTINCT to the query).

Used code from the post by @darre4nbrown in issue #113.

This simple to use and a crucial feature for interacting with a database.

User can do `$db->distinct()->select(...)` to do a distinct selection (add `DISTINCT` to the query).
@JBlond
Copy link

JBlond commented Jun 29, 2015

👍

@Sebb767
Copy link

Sebb767 commented Nov 27, 2015

👍

You should reset distinct mode after executing a query, however.

@SyuTingSong
Copy link
Contributor

I like this feature.
I am thinking about if I provide code $medoo->distinct()->count('account', 'age'), what SQL should be generated.

SELECT DISTINCT COUNT("age") FROM "account"

or

SELECT COUNT(DISTINCT "age") FROM "account"

@Sebb767
Copy link

Sebb767 commented Nov 30, 2015

@SyuTingSong it should be SELECT DISTINCT... since no specific column is given. An overload like $medoo->distinct('age')->... for specifying a specific the distinct column(s) would be great.

@SyuTingSong
Copy link
Contributor

@Sebb767 I merged @sargunster's work to my fork. And I implement auto-reset and SELECT COUNT(DISTINCT "age") FROM "account" additionally.

I guess distinct($column) is inconsistent with medoo's column function way (e.g. COUNT, MAX, MIN, AVG...). The distinct method is more likely a decorator.

You can review my code in commit b7eea7e . Since my fork has merged some others' pull-requests which catfan ignored. I won't create new pull-request here.

Feel free to use and discuss my code.

@HendrikD
Copy link

👍

@SyuTingSong SyuTingSong mentioned this pull request Dec 28, 2015
@froozeify
Copy link

👍

@JanWerder
Copy link

this would be great

@tjmckenzie
Copy link

Upvoted.

@nealoke
Copy link

nealoke commented Jun 21, 2017

+1

@adarshmadrecha
Copy link

@SyuTingSong any plan for implementing this? I am really looking forward to this method.

@zerowebcorp
Copy link

Missing this piece

@sargunv
Copy link
Author

sargunv commented Dec 2, 2020

Seems like this project is no longer maintained, closing this old PR to clear my queue.

@sargunv sargunv closed this Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.