This topic is locked
[SOLVED]

 Lookup Wizard WHERE statement

3/20/2017 6:34:47 PM
PHPRunner General questions
H
Hertz2P author

I have two WHERE clause statements that both work as valid WHERE expressions in the Lookup Wizard . I need to combine them so that both sets of results populate the lookup wizard. I've tried many different combinations of php and SQL, but haven't found the correct way to write the expression.
The two statements that currently work are:

"foreman = '".$_SESSION["UserName"]."'"
"foreman = ''"


The first finds all workers that are assigned to the currently logged in foreman, by checking the "foreman" field of each employee against his username. The second one finds all currently unassigned employees.
Can anyone enlighten me on the correct way to make an OR statement in this situation?
Thanks!

lefty 3/20/2017



I have two WHERE clause statements that both work as valid WHERE expressions in the Lookup Wizard . I need to combine them so that both sets of results populate the lookup wizard. I've tried many different combinations of php and SQL, but haven't found the correct way to write the expression.
The two statements that currently work are:

"foreman = '".$_SESSION["UserName"]."'"
"foreman = ''"


The first finds all workers that are assigned to the currently logged in foreman, by checking the "foreman" field of each employee against his username. The second one finds all currently unassigned employees.
Can anyone enlighten me on the correct way to make an OR statement in this situation?
Thanks!



This should work
" foreman = ' ' " OR " foreman = '". $_SESSION["UserName"]."' "

H
Hertz2P author 3/20/2017

[/quote]

This should work
" foreman = ' ' " OR " foreman = '". $_SESSION["UserName"]."' "

[/quote]
Thanks for the response. I should have mentioned I tried that one, and I also tried many others that I can't even remember. Here's another one I do remember:

" foreman = ' ' " || " foreman = '". $_SESSION["UserName"]."' "


In both these cases, the lookup wizard returned all values in the Table Field, rather than just the two small groups desired.
Maybe it's a bug in 9.7, or maybe OR statements don't work in this spot, or maybe I just haven't tried the correct way to do it.. I'm hoping it's the latter.

lefty 3/20/2017





This should work
" foreman = ' ' " OR " foreman = '". $_SESSION["UserName"]."' "

[/quote]
Thanks for the response. I should have mentioned I tried that one, and I also tried many others that I can't even remember. Here's another one I do remember:

" foreman = ' ' " || " foreman = '". $_SESSION["UserName"]."' "


In both these cases, the lookup wizard returned all values in the Table Field, rather than just the two small groups desired.
Maybe it's a bug in 9.7, or maybe OR statements don't work in this spot, or maybe I just haven't tried the correct way to do it.. I'm hoping it's the latter.

[/quote]
I have this in one of my projects and it works fine

" fldtype = 'Display' || fldtype = 'Both' "
Here is another one that works that I have " (fldtype='Display' or fldtype='Both') and (flddivision = '" . $_SESSION["flddivision"] . "' or fldgroup = '" . $_SESSION["fldgroup"]. "') "
Must have something to do with foreman = ''
Don't forget in the project itself Test, it will not work because of the $_SESSION value . Have to test in application output . Just in case.

H
Hertz2P author 3/20/2017



This should work
" foreman = ' ' " OR " foreman = '". $_SESSION["UserName"]."' "


Thanks for the response. I should have mentioned I tried that one, and I also tried many others that I can't even remember. Here's another one I do remember:

" foreman = ' ' " || " foreman = '". $_SESSION["UserName"]."' "


In both these cases, the lookup wizard returned all values in the Table Field, rather than just the two small groups desired.
Maybe it's a bug in 9.7, or maybe OR statements don't work in this spot, or maybe I just haven't tried the correct way to do it.. I'm hoping it's the latter.

[/quote]
I have this in one of my projects and it works fine

" fldtype = 'Display' || fldtype = 'Both' "
Here is another one that works that I have " (fldtype='Display' or fldtype='Both') and (flddivision = '" . $_SESSION["flddivision"] . "' or fldgroup = '" . $_SESSION["fldgroup"]. "') "
Must have something to do with foreman = ''
Don't forget in the project itself Test, it will not work because of the $_SESSION value . Have to test in application output . Just in case.

[/quote]
Hi John,
I have it running live. I can confirm that both the WHERE statements I pasted work just fine on their own. I just can't seem to get them to work together for some reason. 'foreman' is just a field in the same table where the drop-down data field is located. It seems fairly simple, and I know I should have it solved by now.. Might just be a bug. It's new code, so I've never run it from an older version.

Y
YCH 3/21/2017

Just a guess and unchecked, try this :
" foreman = ' ' OR foreman = '". $_SESSION["UserName"]."'"

H
Hertz2P author 3/21/2017



Just a guess and unchecked, try this :
" foreman = ' ' OR foreman = '". $_SESSION["UserName"]."'"


Bingo! I can't believe I didn't try one set of outside quotes.. Thanks so much!