Answer the question
In order to leave comments, you need to log in
How to get a value from the database by 2 elements?
Hello!
I have a database that consists of two columns (member, date)
My goal is to enter two numbers into a cell from the date column, something like 10, 18
And so that when querying date = 18 this cell is displayed, otherwise it turns out only when requesting 10, 18 the desired cell is displayed.
sqlite3
Thank you for your help!
Answer the question
In order to leave comments, you need to log in
Sqlite has no such type as an array, so you can't query for a specific array element. Therefore, there are two options - do not use sqlite or store dates in a separate table related via a foreign key to the current one
And what for 10 if it is necessary to deduce 18? And if you wrote down 10.18, then the value will be like that, or try using the .split function into a variable and display the necessary indices.
sql databases define an array - like a table i.e. you need an array - make a linked table
table (id, member)
dates (table_id, date)
with the created foreign key index dates.table_id -> table.id,
respectively, when you request data from the table, then join them with dates using join (depending on left/right/inner join tasks)
select distinct table.id, table.member from table left join dates on table.id-dates.table_id where dates.date=18
will return one record from table if they have associated dates with value 18 select * from table where dates like '%;18%'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question