Skip to main content

Or

or can be used with where to filter records to include records where any of the condition is true.

note

Primary key is required for or query to work properly.

Sql

Select * From Table_Name
Where
Column1=some_value
or
Column2=some_another_value;

JsStore

var results = await connection.select({
from: "Table_Name",
where: {
column1: some_value,
or: {
column2: some_another_value
}
}
});
//results will be array of objects.
console.log(results);

Example

More Examples

Let's understand some more examples query, which will help us to write any kinda of or query as per our requirements -

Select * from Table_Name where Column1=value1 or Column2=value2 or Column3=value3

connection.select({
from: "Table_Name",
where: {
Column1: value1,
or: {
Column2: value2,
or:{
Column3: value3
}
}
}
});

The above syntax can be also written as -

connection.select({
from: "Table_Name",
where: {
Column1: value1,
or: [
{
Column2: value2
},
{
or:{
Column3: value3
}
}
]
}
});

Select * from Table_Name where Column1=value1 and (Column2=value2 or Column3=value3)

connection.select({
from: "Table_Name",
where: [{
Column1: value1
},
{
Column2: value2,
or: {
Column3: value3
}
}
]
});

Select * from Table_Name where Column1=value1 or (Column2=value2 and Column3=value3)

connection.select({
from: "Table_Name",
where: [{
Column1: value1
},
{
or: {
Column2: value2,
Column3: value3
}
}
]
});

Select * from Products where supplierId = 1 and (categoryId = 1 and price = 18) or(categoryId = 2 and price = 39)

select({
from: "Products",
where: [{
supplierId: 1,
}, {
categoryId: 1,
price: 18,
}, {
or: {
categoryId: 2,
price: 39,
}
}]
});