Re: query error
| From: | Ignatius Reilly | Date: | Mon, 03 Nov 2003 13:44:00 +0000 |
| Subject: | Re: query error | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-21959@lists.php.net to get a copy of this message | ||
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" <lamoreira@bes.pt>
To: "Rinku Shivnani" <rinku@banas.guj.nic.in>; <php-windows@lists.php.net>
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" <rinku@banas.guj.nic.in>
> To: <php-windows@lists.php.net>
> 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
>
>