This is a useful trick when generating conditions dynamically in SQL

$sql = "SELECT
            ...
            WHERE 1 = 1
" ;
foreach ( $conditions as $condition ) {
    $sql .= "AND {$condition}" ;
}

Ignatius
_________________________
----- Original Message -----
From: "Luis Moreira" <[EMAIL PROTECTED]>
To: "Rinku Shivnani" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, November 03, 2003 2:23 PM
Subject: Re: [PHP-WIN] query error


> What is this doing here ?
>
> where 1=1
>
> This is always true
>
>
>
> ----- Original Message -----
> From: "Rinku Shivnani" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, November 03, 2003 12:50 PM
> Subject: [PHP-WIN] query error
>
>
> > SELECT types, comp_name, modal, to_char(manufact_dt,'dd/MON/yyyy'),
> > to_char(purchase_dt,'dd/MON/yyyy'), dealer_nm, cc, avg,
> > to_char(rto_passing_dt,'dd/MON/yyyy'), veh_no, color, appro_val,
> extra_info,
> > to_char(dt,'dd/MON/yyyy'), necessary_info, name, email_id, village,
place,
> > taluka, ph_no, extra FROM vehicle where 1=1 and wheel='Y|L jCL,Z' and
> > flag='n'
> >
> > question :
> > Here in my database wheel column have the same value but then even why I
> > am not getting any  row as output for this query.
> >
> > Pls George help me
> >
> > Regards,
> > Rinku
> >
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to