I have written a search query with good results but now I need to add a new parameter to it and I am getting no where. I am brand new so this is probably something very easy I am overlooking.
Here is what I have:
SELECT * FROM SOHEAD WHERE upper($field)='$find' AND STATUS='P' ORDER BY SO_NO DESC
That is working great.
Now I need to add another variable to the status. I need to return all entries that =$find and that have a status of p or v. I have tired about every combination but I am stuck:
This returns only staus=p
SELECT * FROM SOHEAD WHERE upper($field)='$find' AND STATUS='P' OR 'V' ORDER BY SO_NO DESC
This returns an error:
SELECT * FROM SOHEAD WHERE upper($field)='$find' AND STATUS='P' OR upper($field)='$find' AND STATUS= 'V' ORDER BY SO_NO DESC
This returns correctly on status=p but returns all status=v
SELECT * FROM SOHEAD WHERE upper($field)='$find' AND STATUS='P' OR STATUS='V' ORDER BY SO_NO DESC
Is there something easy I am missing?
Thanks
A search question
Moderator: General Moderators
Re: A search question
Perhaps try different approaches;
Code: Select all
SELECT * FROM SOHEAD WHERE UPPER($field)='$find' AND STATUS IN('P','V') ORDER BY SO_NO DESCSELECT * FROM SOHEAD WHERE UPPER($field)='$find' AND (STATUS='P' OR STATUS='V') ORDER BY SO_NO DESCRe: A search question
Yes, I tried the first one and it worked perfectly.
Thanks. I am learning slowly but surely.
Thanks. I am learning slowly but surely.
Re: A search question
That's the only way!micknc wrote:Yes, I tried the first one and it worked perfectly.
Thanks. I am learning slowly but surely.