Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Mumbai, India

    Unanswered: Checking for CONCAT() in WHERE clause

    Any way to get this working ?
    SELECT *,
    CONCAT(`field1`, `field2`,`field3`,`field4`,`field5`) AS Uniq
    FROM `table1` WHERE Uniq = 'somevalue'
    Neither does this work too.
    SELECT *,
    CONCAT(`field1`, `field2`,`field3`,`field4`,`field5`) AS tbl1.Uniq
    FROM `table1` tbl1 WHERE tbl1.Uniq = 'somevalue'

  2. #2
    Join Date
    Jul 2004
    Dundee, Scotland
    It is not possible to use a field alias in the WHERE clause. Your solution would be either to check the value each field in the WHERE clause, or possibly to use an IF condition in your SELECT clause. If neither of these alternatives are appropriate you might decide to make use of a temporary table.


    "The alias is used as the expression's column name and can be used in GROUP BY, ORDER BY, or HAVING clauses."

    "It is not allowable to use a column alias in a WHERE clause, because the column value might not yet be determined when the WHERE clause is executed."
    Last edited by yellowmarker; 01-07-06 at 12:51.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts