With a little side of applesauce...

Tuesday, April 28, 2009

Postgresql - using AS and WHERE together

I found this neat trick to perform the following, (which won't work due to the this):

SELECT fname || ' ' || lname AS fullname
FROM users
WHERE fullname LIKE 'Joe%'


The example is:

SELECT fullname
FROM (
SELECT fname || ' ' || lname
AS fullname
FROM users
) as a
WHERE fullname LIKE 'Joe%'


This was stolen from here:
http://www.sitepoint.com/forums/showthread.php?t=395416

No comments: