RE: help with query

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

 



Thanks Jim, worked like a charm.

> -----Original Message-----
> From: Jim Lucas [mailto:lists@xxxxxxxxx]
> Sent: Thursday, June 07, 2012 4:08 PM
> To: Jack
> Cc: PHP
> Subject: Re:  help with query
> 
> On 06/07/2012 09:37 AM, Jack wrote:
> > $query = "select a.startdate, a.articleid, c.name, a.title, a.intro,
> > a.datecreated from articles as a, categories as c where (a.startdate =
> > -1 or a.startdate<= {$now}) and (a.enddate = -1 or a.enddate>= {$now})
> > and a.categoryid = c.categoryid order by a.startdate DESC";
> 
> $query = "
> 	SELECT	a.startdate,
> 		a.articleid,
> 		c.name,
> 		a.title,
> 		a.intro,
> 		a.datecreated
> 	FROM	articles as a,
> 		categories as c
> 	WHERE	(
> 		a.startdate = -1
> 		OR
> 		a.startdate <= {$now}
> 		)
> 	AND	(
> 		a.enddate = -1
> 		OR
> 		a.enddate >= {$now}
> 		)
> -- This line must stay, it is limiting the combination of the data from
> -- both tables
> 	AND	a.categoryid = c.categoryid
> -- You need to add this line to make it work, but keep the previous line
> 	AND	a.categoryid = 1
> 
> 	ORDER BY a.startdate DESC
> ";
> 
> --
> Jim Lucas
> 
> http://www.cmsws.com/
> http://www.cmsws.com/examples/
> http://www.bendsource.com/

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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux