05.02.2021, 07:39
Hi
I am doing some quries to the database to be able to find some objects depending on different values. I have been able to find it, but I want some help to understand why things are as they are.
The code I was trying to use was:
This returned an empty table.
I then changed the code to
This returned a table with the information I wanted.
I have used the structure from the first example before, and it has worked, but now it did not. Why is it so?
I am sure I have done something wrong in the first example, I just do not understand what it is.
I am doing some quries to the database to be able to find some objects depending on different values. I have been able to find it, but I want some help to understand why things are as they are.
The code I was trying to use was:
Code:
newNavn = db:getall('SELECT name FROM objects WHERE name LIKE ? AND name LIKE ?', origObjKode, term )
This returned an empty table.
I then changed the code to
Code:
newNavn = db:getall('SELECT name FROM objects WHERE name LIKE "%'.. origObjKode ..'%" AND name LIKE "%'.. term ..'%"')
I have used the structure from the first example before, and it has worked, but now it did not. Why is it so?
I am sure I have done something wrong in the first example, I just do not understand what it is.
There are 10 kinds of people in the world; those who can read binary and those who don't