Using Aliases and Fulltext

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Using Aliases and Fulltext

Post by seodevhead »

I have a column in a table called 'names'

A Fulltext index was created in the CREATE table definition with FULLTEXT (names)

My SELECT query is like so:

Code: Select all

"SELECT names AS n FROM table WHERE MATCH(n) AGAINST('my keywords')";
Can I do this??? Can I use a column's alias in a fulltext WHERE clause??? Thanks.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Yes, you should be able to do it. Is it not working?
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

No, it's not working :(

Here is the error:

Code: Select all

MySQL Error: Unknown column 'n' in 'where clause'
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

From http://dev.mysql.com/select:
MySQL Manual wrote: 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.
So, you just need to use the full column name in the WHERE clause :)

Mac
Post Reply