NYCPHP Meetup

NYPHP.org

[nycphp-talk] problem with mysql select query with unusual criteria

soazine at pop.erols.com soazine at pop.erols.com
Mon Oct 20 15:46:23 EDT 2003


actually I rewrote the query to be a bit more clear..

Ok I finally figured out the query I want to write, here is the Oracle
version of the query:

select i.enrollment_year, (select p.allowed from permissions p, partners q,
intern_complete_application a where p.intern_id = a.intern_id and
p.intern_id = 821 and p.partner_id = q.partner_id and upper(q.partner_name)
= 'ECSU' and upper(a.has_ecsu_essay) = 'Y') as allowed, ica.*
from interns i, intern_complate_application ica
where i.intern_id = ica.intern_id
and i.intern_id = 821;

I hope that clears things up a bit.

Phil

Original Message:
-----------------
From: Adam Maccabee Trachtenberg adam at trachtenberg.com
Date: Mon, 20 Oct 2003 15:37:37 -0400 (EDT)
To: soazine at erols.com, talk at lists.nyphp.org
Subject: Re: [nycphp-talk] problem with mysql select query with unusual
criteria


On Mon, 20 Oct 2003, soazine at pop.erols.com wrote:

> SELECT distinct i.enrollment_year,
> IF (p.intern_id = i.id AND p.intern_id = '821' AND p.partner_name =
> q.partner_name AND upper(q.partner_name) = 'ECSU' AND
> upper(ica.has_ecsu_essay) = 'Y'), '1', '0' AS allowed,
> ica.*
> FROM interns i, intern_complete_application ica, permissions p, partners q
> WHERE ica.intern_id = i.id
> AND ica.intern_id = '821'
> AND upper(ica.has_ref_letter_1) = 'Y'
> AND upper(ica.has_ref_letter_2) = 'Y'
> AND upper(ica.has_transcript) = 'Y'
> 
> I get syntax errors on this query, and every other combination gives me
> syntax errors or wrong data. I have been trying for 2 days to get this
> query and it's either that or I write this horrifically bloated PHP method
> to do the same thing (it works but it takes about 15 seconds to execute
the
> whole thing):

Are you sure that's the correct place to put the ()s w/r/t the IF? I
would look that up on mysql.com.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





More information about the talk mailing list