RE: WHERE-ing an alias...

2002-06-06 Thread Jay Blanchard
[snip] Thanks so much. There was a slight syntax change, replacing your first ORDER BY with a GROUP BY, but it worked. [/snip] Yep *slapping forehead* I saw that I had one too many ORDER BY's there and forgot to send an update. :) Glad it helped! Jay mysql, sql, query "It's hip to snip!"

RE: WHERE-ing an alias...

2002-06-06 Thread Ian M. Evans
[snip] WHERE ap_type='Original Movie Poster' ORDER BY sort_title ASC HAVING sort_title LIKE 'G%' ORDER BY sort_title ASC You may have to swap the HAVING and ORDER BY lines of the query, [/snip] Thanks so much. There was a slight syntax change, replacing your first ORDER BY with a GROUP BY, but i

Re: WHERE-ing an alias...

2002-06-05 Thread Keith C. Ivey
On 5 Jun 2002, at 14:30, Ian M. Evans wrote: > As per previous suggestions, I use sort_title so that film titles like > "The Godfather" get sorted as "Godfather". In the above select I was > trying to narrow the search down so I could grab all the films that > started with 'G' but still using the

RE: WHERE-ing an alias...

2002-06-05 Thread Jay Blanchard
[snip] SELECT posterdata.*, IF (aptitle LIKE 'The %',SUBSTRING(aptitle,5),IF (aptitle LIKE 'A %',SUBSTRING(aptitle,3),IF (aptitle LIKE 'An %',SUBSTRING(aptitle,4),aptitle))) AS sort_title FROM posterdata WHERE ap_type='Original Movie Poster' AND sort_title LIKE 'G%' ORDER BY sort_title ASC As per

WHERE-ing an alias...

2002-06-05 Thread Ian M. Evans
Ah, after I write my SQL SELECT query I discover that you can't use WHERE with an alias. Here's what I'm trying to do: SELECT posterdata.*, IF (aptitle LIKE 'The %',SUBSTRING(aptitle,5), IF (aptitle LIKE 'A %',SUBSTRING(aptitle,3),IF (aptitle LIKE 'An %',SUBSTRING(aptitle,4),aptitle))) AS sort_t