SELECT statement trouble

wxdqz

New Member
I am trying to write a SELECT statement that satisfies a number of different situations. I am guessing my logic is wrong. Here it is:

$cur = odbc_exec ($conn, "
SELECT DISTINCT jimfile.jim_job, jimfile.hf_01, jimfile.close_1, jimfile.press_date, jimfile.job_cunm, jimfile.lark_qty_1, jimfile.lark_um_1, jimfile.lark_sz1, jimfile.convhrs_1, jimfile.job_desc, jimcust.eaddtl_desc_1, jimfile.drm_01, job.j_stat, jimfile.open_1, jimfile.conv_date, jimfile.lark_sz1, job.job_id
FROM covmgr.jimfile,
covmgr.job,
covmgr.jimcust
WHERE job.job_id = jimfile.jim_job AND
jimfile.jim_job = jimcust.jimc_job AND
job.j_stat = 0 AND
(jimfile.drm_01 > 0 AND jimfile.open_1 > 0) OR
(jimcust.fpm_c1 > 0 AND jimcust.qeach_b1 > 0)


ORDER BY
close_1 asc,
hf_01 desc,
conv_date asc
");

Basically, I would like statements preceding the ( ) to always be true. Then, just as the ( ) say, each statement must be true in the ( ) OR the values in the next ( ) statement must be true.

For some reason, when I run this query, it queries forever, then times out.

Thanks for any help.
 
Back
Top