Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex sql parsing problems #1727

Closed
banjuer opened this issue Mar 1, 2021 · 2 comments
Closed

Complex sql parsing problems #1727

banjuer opened this issue Mar 1, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@banjuer
Copy link

banjuer commented Mar 1, 2021

Describe the problem

i want to use complex sql to implement dynamic query, but didn't get the expected results.

  • my purpose: dynamically query tasks that were completed last month

  • query sql:

select  *
from blocks
where type='i' and path = '/work.md' and markdown like '%[x]%'
and (
    created between(SELECT strftime('%Y%m%d',date('now','start of month','-1 month'))) and (SELECT strftime('%Y%m%d',date('now','start of month','-1 day')))
        or updated between(SELECT strftime('%Y%m%d',date('now','start of month','-1 month'))) and (SELECT strftime('%Y%m%d',date('now','start of month','-1 day')))
)

the result:
image

Expected result

I don't know how sql parsing is implemented in SiYuan, and just explore whether this complex sql can be used

Screenshot or screen recording presentation

see figure above

Version environment

  • Version: v1.0.8 / Kernel v1.0.8
  • Operating system:
  • Browser (if used):

Log File

null

More information

null

@88250
Copy link
Member

88250 commented Mar 1, 2021

created and updated is not DATATIME/DATE type, it is TEXT type, so try using < or > comparison operator for it.

@banjuer
Copy link
Author

banjuer commented Mar 1, 2021

created and updated is not DATATIME/DATE type, it is TEXT type, so try using < or > comparison operator for it.

I tried it but it didn't work.

query sql

select  * from blocks where type='i' and path = '/work.md' and markdown like '%[x]%' and created >=(SELECT strftime('%Y%m%d',date('now','start of month','-1 month'))) and created<=(SELECT strftime('%Y%m%d',date('now','start of month','-1 day')))

by the way, the strftime() function's result type was TEXT

image

@88250 88250 self-assigned this Mar 9, 2021
@88250 88250 added the Bug label Mar 9, 2021
@88250 88250 added this to the 1.1.2 milestone Mar 9, 2021
@88250 88250 closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants