Replies: 1 comment 14 replies
-
Hello and welcome to SQLPage! I would love to know a little bit more about what you are building: a 1TB SQLite file sure isn't common! About searching only the fields that were filled by the user, I think what you are looking for is a simple sequence of AND and OR operators: select * from table1
where
($field1 = '' OR field1 = $field1) AND
($field2 = '' OR field2 = $field2) AND
($field3 = '' OR field3 = $field3); Or am I missing something? |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I am fairly new to sql and very new to sqlpage. Apologies for any misunderstandings or omissions.
I am hoping to use it as a simple search page (and ideally csv exporter) for a big database that I frequently need to query. Adding data or changing the data in the db is not in scope, I just need a search page that looks like this:
That looks great, but it does not really do what I want under the hood. what I want is for sqlpage to run a query based on what feilds are filled out and what feilds are not. So when "Field1" and "Field5" are filled out it runs:
SELECT * FROM "Table1" WHERE "field1" = "$Field1" AND "field5" = "$Field5";
and if 1, 3 5 are filled out then query should be
SELECT * FROM "Table1" WHERE "field1" = "$Field1" AND "field3" = "$Field3" AND "field5" = "$Field5";
but I cant figure out how to structure the sql in a way that avoids me having to write out all 64 permutations. I see in this discussion something that sort of works, but when I implement a slightly modified version of the CASE test in the answer to that example the speed of the query takes a massive hit, to the point that its essentially unusable.
This sqlite database is more then 1TB and I don't have great hardware, but even so the difference the case test and the specific search is staggering.
I see in other threads the author mentioning that arbitrary sql queries are not really supported, but I dont think thats what I want. I have a list of specific queries I want to run, I just dont want to have to type them all out (the number of feilds I want included will probably grow tbh)
here is my current index.sql, any advice or suggestions on how I can get this working would be greatly appreciated.
thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions