As per the title, what would be the PHP Mongo equivalent of something like this in SQL:
SELECT DISTINCT(field) FROM table WHERE someCondition = 1
I’ve read looked at this table but I don’t see how to map db.users.distinct('last_name') into PHP.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just issue a command and set the
distinctkey.Take a look at the following example from the docs:
Finding all of the distinct values for a key.
The above example will output something similar to: