whats wrong in my query

alaric

Well-known member
Joined
Oct 12, 2005
Messages
53
Programming Experience
Beginner
[RESOLVED] whats wrong in my query

hi,

Im building a form on wich the user can choose to send an email to people with email, depending (filtered) on criteria.
The filtered students are shown in a listview.

my sql query is;
VB.NET:
[SIZE=1]
strSQL = "SELECT DISTINCT TAdresBoek.CursistID, TAdresBoek.AchterNaam + ', ' + TAdresBoek.VoorNaam + ISNULL(+ ' ' + TAdresBoek.TussenVoegsel, '') AS Naam, " _
& " TAdresBoek.EmailAdres, TWeekdag.Weekdag AS Weekdag, TInschrijving.Plezier, TInschrijving.OpNivo, TCursussen.Cursus AS Cursus, " _
& " TBetalingen.Betaald " _
& " FROM TInschrijving " _
& " INNER JOIN " _
& " TWeekdag ON TInschrijving.Weekdag = TWeekdag.WeekDagid INNER JOIN " _
& " TLocaties ON TInschrijving.Locatie = TLocaties.LocatieID INNER JOIN " _
& " TCursussen ON TInschrijving.Cursus = TCursussen.CursusID INNER JOIN " _
& " TBetalingen ON TInschrijving.InschrijvingsID = TBetalingen.Inschrijvingsid RIGHT OUTER JOIN " _
& " TAdresBoek ON TInschrijving.CursistID = TAdresBoek.CursistID CROSS JOIN " _
& " TDansSoort " _
& " WHERE TAdresBoek.EmailAdres <> ' '"
strSQL = strSQL & strActiefClause & strOpNivoClause & strPlezierClause & strStudentClause _
& strACardClause & strShowgroepClause & strBetaaldClause & strWeekdagClause
[/SIZE]

all filters work as I planned But then;
as soon as I start filtering with Weekdays "Monday", "Tuesday" etc. ( strWeekDayClause will be like AND TWeekdag.Weekdag = 'Maandag' OR TWeekdag.Weekdag = 'Dinsdag')

using a query tool I see that "suddenly" also Emailaddress with a value NULL are shown! I ONLY want the query to return the ones with an emailaddress.:confused:

ofcourse my listview blows, because it can's display a subitem with an Empty string

someone?
how do I make the right query?

thx in advance
 
Last edited:
Note that an empty string and a null value are NOT the same thing. You are using them interchangeably but they are not. Your query is excluding records where the e-mail address is an empty string. If you have records where the e-mail address is actually a null value then they will be returned by that query.
 
Resolved

THANKS!!
I got emtpy stings in my DB when looping through textboxes and put these in the DB
I notice that I have several (test) records with "empty strings"
 
Last edited:
Back
Top