NYCPHP Meetup

NYPHP.org

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

Adam Maccabee Trachtenberg adam at trachtenberg.com
Mon Oct 20 15:37:37 EDT 2003


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!




More information about the talk mailing list