Ravi Hariani
Ravi Hariani

Reputation: 21

mongo db to sql conversion 1

db.music.find({deleted: {$ne: true}});

the above code is in mongo db

I want to know how to write the equivalent for this in sql

thank you

Upvotes: 1

Views: 47

Answers (2)

GavKilbride
GavKilbride

Reputation: 1569

Assuming your storing [deleted] as a bit or nullable bit then :

Select * from [music] where [deleted] != 1

But you can't use sql to query MongoDB, you know that right?

Upvotes: 1

Cydrick Trudel
Cydrick Trudel

Reputation: 10507

select * from music where deleted != true;

or, optimized:

select * from music where deleted == false;

Depending on the version of SQL, the false could be 'false', 0 or '0'

Assuming:

  • You're already on the right database (no need to put use my.db at the beginning of your script)
  • Your deleted column is of type boolean or bit.

Upvotes: 1

Related Questions