Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (47.6k points)

I would like to execute the following query:

db.mycollection.find(HAS IMAGE URL)

What should be the correct syntax?

2 Answers

0 votes
by (106k points)

The query for “is not null” in Mongodb in pymongo you can use the following query:-

db.mycollection.find({"IMAGE URL":{"$ne":None}});

This is because pymongo represents mongo "null" as python "None".

0 votes
by (108k points)

Follow the following syntax:

db.collection1.find({ 'fieldname1' : { $exists: true, $ne: null } });

When $exists is true, $exists matches the documents that contain the particular field, including documents where the field value is null. If the value is false, the query returns only the documents that do not consist of the field. $ne picks the documents where the value of the field is not equal to the particularized value. This incorporates documents that do not contain the field.

Related questions

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
asked Sep 26, 2019 in SQL by chandra (29.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories