Answer the question
In order to leave comments, you need to log in
How to make a request for a field to be empty?
Hello. Soon I'll start howling from my war :)) I'm trying to connect with an old access database using odbc and pdo. And most of the queries I'm used to don't work!
Here is an example of the simplest request... SELECT * FROM \"Детали\" WHERE \"Чертеж\"!=''
Doesn't want to work at all. If you set a condition for "equal", then they work out. And that's it ..
I also don't know how to make him friends with a request to two tables at once $q="SELECT * FROM \"Детали\", \"Изделия\"";
- they will also swear))
Has anyone fought with such mammoths? :)))
Answer the question
In order to leave comments, you need to log in
Strange you check for emptiness. Isn't it necessary to write \"Drawing\" IS NOT NULL? And in the second query, I think you have a problem with formatting or with Products, why do you write "\Products\" and not \"Products\"??
I'm not an expert in SQL-Like languages, but does MS Access need quotes?
Try something like this:SELECT * FROM Детали WHERE Чертеж<>""
So, this is not the way to check for an empty field. It is necessary to understand the difference between "an empty string" and Null
, the simplest thing for an access is to add an empty string to the string, then NULL will also become a string.
MyValue = trim(MyValue) & ""
what is being done here - if the string value of MyValue is all spaces, it will turn into ""
If the string value is NULL - it will turn into ""
select * from mytable where trim(MyValue) & "" <> "" -- this query will work.
Now, two tables:
select * from mytable mt
join mytable2 mt2 on mt.id = mt2.id_item
where trim(mt.MyValue) & "" <> ""
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question