Re: query error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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:  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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux