P parijs Active Member Licensed User Longtime User Oct 13, 2014 #1 I want to sellect thinks from A,B,C,D,E but only if Z = "yes" in the db So A also corresponded with what I look but because z = "no", I do not want it I use the code below but it does not work. Code: Copy oRst = SQL.ExecQuery2("SELECT * FROM visit WHERE wijk = ? OR wijk = ? OR wijk = ? OR wijk = ? OR wijk = ? AND Z = ?", Array As String (A, B, C, D, E, "yes"))
I want to sellect thinks from A,B,C,D,E but only if Z = "yes" in the db So A also corresponded with what I look but because z = "no", I do not want it I use the code below but it does not work. Code: Copy oRst = SQL.ExecQuery2("SELECT * FROM visit WHERE wijk = ? OR wijk = ? OR wijk = ? OR wijk = ? OR wijk = ? AND Z = ?", Array As String (A, B, C, D, E, "yes"))
M Mahares Expert Licensed User Longtime User Oct 13, 2014 #2 Here you go: Please note that I assume wijk and Z are table fields here. Code: Copy oRst = SQL.ExecQuery("SELECT * FROM visit WHERE wijk IN('A','B','C','D','E') AND Z = 'yes'") Last edited: Oct 13, 2014 Upvote 0
Here you go: Please note that I assume wijk and Z are table fields here. Code: Copy oRst = SQL.ExecQuery("SELECT * FROM visit WHERE wijk IN('A','B','C','D','E') AND Z = 'yes'")
Straker Active Member Licensed User Longtime User Oct 13, 2014 #3 Or just place all your OR inside parenthesis leaving AND outside. But mahares code is better. Upvote 0