Abdul Sammad
Abdul Sammad

Reputation: 23

How can I use Logical operators (AND, OR, NOT) in adonis js using mysql?

I want to get data from the database on multiple conditions but I did not find any solution on how to apply logical operators. Need your help. Here is my query in A

const nftRarityInfo = await Database.query().select('rarity').from('rarity_info').where('id','=', detailData[0].rarity_id AND "is_active", "=",'1')
rarity_info is table name and I want data that passes the condition. there are multiple conditions. First one is match the id and second one is is_Active must be 1. So I want data that passes these two conditions. I m new in Adonis js and programming. Kindly help me out that how can i do this

Upvotes: 0

Views: 534

Answers (1)

Abdul Sammad
Abdul Sammad

Reputation: 23

Finally I got solution by myself. Following query works perfect for me:

const nftRarityInfo = await Database.query().select('rarity').from('rarity_info').where('id','=', detailData[0].rarity_id ).andWhere('is_active','=','1')

Upvotes: 1

Related Questions