Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need an advise on this select sql Fellows

Status
Not open for further replies.
Jan 20, 2007
237
US
Hi,
with the Sql code below, i am not able to get the result i want, i know something is wrong but here i am to find out.
just want to get displayed in a browse, for that particular job _no when rel_code=0 and rel_code =6

Code:
SELECT  ball_no,draw_no, rel_code FROM eng_jobs WHERE job_no="124278" AND rel_code=6 OR rel_code=0 into cursor junkR
this does not work for me i know is wrong , but don't find the filter to get it right
Thanks
 
Hi Mike,
If i do it like or w/o the parentheses, i get same result, it does not filter that specific job_no, i will do for all job_nos, i need it for the specific job_no = whatever value i put in here
Thanks
 
Well, in any case you need parentheses around [tt]rel_code=6 OR rel_code=0[/tt] because AND takes precedence over OR. So, your original query would give all "124278" jobs that have rel_code = 6, and also all jobs (regardless of job no.) where rel_code is 0.

But, given that you are still getting the wrong result .... Is the job no. field wider than 6 characters? If so, either put ALLTRIM() around job_no, or use the [tt]==[/tt] operator when testing for "124278" (rather than a single [tt]=[/tt]).

If that still doesn't work, perhaps you could show us an example of your data, and indicate what result you are getting.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

Job_no field in eng_jobs it is a char (6), so for a reason even if put alltrim(job_no)="124278" or job_no =="124278" i still get in the brow any job no that has those rel_code.
Thanks
 
Ok mike,
probably i misunderstood you, i did like this now and it is fine
And (rel_code = 6 Or rel_code = 0)

the previous way ,i did was AND (rel_code = 6) Or (rel_code = 0) and this way it is not correct
Thanks
 
Nothing to be sorry, i should assumed that was you meant but with the knowledge i have, it is not possible to do it right from the first time, my apologies to you and thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top