Closed xuyongweb closed 1 year ago
I don't understand the question - can you please give me what query you are runing and what you are expecting ?
install idbstudio and view your data - https://github.com/ujjwalguptaofficial/idbstudio
I feel somewhere your data is being updated to null
I found the problem. The main and secondary tables were checked correctly on the reverse, but the data was checked on the opposite side of SQL file
`select({
from: "Orders",
order: {
by: 'Orders.customerId',
type: 'asc' //supprted sort type is - asc,desc
},
join: {
with: "Customers",
type: "left",
on: "Orders.customerId=Customers.customerId",
as: {
customerId: 'cId'
}
}
})`
The main table is Orders, and the secondary table is the customerId of the Customers main table. The associated secondary table is customerId It should be that one data in the main table corresponds to multiple data in the secondary table, but currently only the first data in the main table is associated with the secondary table, and the rest are null
this is because you are using left
join which means you want all data from first table even if data does not match in second table. If you want all data matched then use inner
join.
I hope this makes sense.
Thinks,
this is because you are using
left
join which means you want all data from first table even if data does not match in second table. If you want all data matched then useinner
join.I hope this makes sense. Thinks But there is also a scenario where if the main table Orders.customerId is empty, using 'inner join' will not be able to find data with empty main table Orders.customerId, just like some chat data have attachments, some do not have attachments, and some chat data share the same attachment, but using 'inner join' can only find data with attachments, and data without attachments cannot be found
select Messages.* , Chatappendixs.id as Chatappendixsid,Chatappendixs.uuid as Chatappendixsuuid,Chatappendixs.content as Chatappendixscontent from Messages left join Chatappendixs on Messages.appendixId=Chatappendixs.id where 1=1 and Messages.extra != 10070 and Messages.type='group' and Messages.unread=1 order by Messages.timestamp desc
The above is the syntax for 'sqlite'. The 'left join' of sqlite means that messages without attachments, messages with shared attachments, and messages with only one attachment can be found
I understood what you are trying to say. Let me spend some more time and came back but seems like its a bug.
@ujjwalguptaofficial Thank you very much! I'm sorry to reply to you so late for the Dragon Boat Festival holiday three days ago, but your problem solving efficiency is really gratifying. Thank you again for solving my problem perfectly!
select * from table where ( a = 2 and b = 1 ) or ( a = 1 and b = 2 )
I also have a question about how to use jsstore to rewrite sqlite like this The results of the jsstore query seem different from those of sqlite
it became all or
in the or query, try with array -
select({
from: 'Orders',
where: [{
customerId: 2,
employeeId: 7
}, {
or: {
customerId: 7,
employeeId: 2
}
}]
})
Don't forget to stars the repo :)
select({ from: 'Orders', where: [{ customerId: 2, employeeId: 7, type: 1, delete: false }, { or: { customerId: 7, employeeId: 2, type: 1, delete: false } }] })
If there are other conditional queries, should we write two copies in both the outer layer and the or, for example: delete: false, type: 1
Title
Association query message table appendixId Multiple messages are associated with the uuid of a Chatappendixs table. Only the first one can find the Chatappendixs content, and the remaining few messages cannot be found // Add your title here
Description
Association query message table appendixId Multiple messages are associated with the uuid of a Chatappendixs table. Only the first one can find the Chatappendixs content, and the remaining few messages cannot be found // Add your description here
Note: Description should contains the query, the current output & the expected output. You can use idbstudio to generate the example. `getListWithMsg(data, limit, name) {
}`