WHERE & AS

  • Follow


Hi,

Is it possible to create a field name and then use it in a where
statement?

SELECT
	CONCAT(`Product Index`.`Product_Headings`,' ',COALESCE(`Product
Index`.`Sub_Product_Headings`,''))
	AS `product_name`
FROM `product index`
WHERE product_name LIKE '%Alar%'

This statement errors with Unknown column 'product_name' in 'where
clause'

Not sure if it can be done.

Thanks

A

0
Reply spidercc21 (71) 4/5/2007 12:04:52 PM

"UKuser" <spidercc21@yahoo.co.uk> wrote in message 
news:1175774692.363948.261850@y80g2000hsf.googlegroups.com...
> Hi,
>
> Is it possible to create a field name and then use it in a where
> statement?
>
> SELECT
> CONCAT(`Product Index`.`Product_Headings`,' ',COALESCE(`Product
> Index`.`Sub_Product_Headings`,''))
> AS `product_name`
> FROM `product index`
> WHERE product_name LIKE '%Alar%'
>
> This statement errors with Unknown column 'product_name' in 'where
> clause'
>
> Not sure if it can be done.
>
> Thanks
>
> A
>

Yup (or so I am led to believe)

SELECT
CONCAT(`Product Index`.`Product_Headings`,' 
',COALESCE(`ProductIndex`.`Sub_Product_Headings`,''))
AS `product_name`
FROM `product index`
HAVING product_name LIKE '%Alar%'

Hope it works... 



0
Reply Sean 4/5/2007 12:56:22 PM


On 5 Apr, 13:56, "Sean" <sean.anderson@[nospam]oakleafgroup.biz>
wrote:
> "UKuser" <spiderc...@yahoo.co.uk> wrote in message
>
> news:1175774692.363948.261850@y80g2000hsf.googlegroups.com...
>
>
>
> > Hi,
>
> > Is it possible to create a field name and then use it in a where
> > statement?
>
> > SELECT
> > CONCAT(`Product Index`.`Product_Headings`,' ',COALESCE(`Product
> > Index`.`Sub_Product_Headings`,''))
> > AS `product_name`
> > FROM `product index`
> > WHERE product_name LIKE '%Alar%'
>
> > This statement errors with Unknown column 'product_name' in 'where
> > clause'
>
> > Not sure if it can be done.
>
> > Thanks
>
> > A
>
> Yup (or so I am led to believe)
>
> SELECT
> CONCAT(`Product Index`.`Product_Headings`,'
> ',COALESCE(`ProductIndex`.`Sub_Product_Headings`,''))
> AS `product_name`
> FROM `product index`
> HAVING product_name LIKE '%Alar%'
>
> Hope it works...

Superb - thanks indeed!

A

0
Reply UKuser 4/5/2007 1:08:46 PM

2 Replies
140 Views

(page loaded in 0.041 seconds)

Similiar Articles:













7/27/2012 8:15:56 AM


Reply: