Search Postgresql Archives

Re: Inserting boolean types as an alias?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/02/2013 03:46 PM, Nick wrote:
Hello I am new to this site and also a student. I am working on an assignment
and was wondering if there is a way to make an alias for a boolean? For
example when I am making a table called club_games and it must contain the
memberID, gameID, count, and status as column fields. When I enter the data
for status I want it to say either "unavailable" for false and "available"
for true. but I don't know how to do that.
This is what I have currently for the line that I am specifically talking
about:

INSERT INTO club_Games(memberID, gameID, hardwareID, count, status)
	 VALUES	((SELECT memberID FROM members WHERE name = 'Fred Flinstone'),
(SELECT gameID FROM games WHERE name = 'Jurrasic Park'), NULL, 1, 'true');

when I do the SELECT * FROM club_Games this is my output:

id     gameid        memberid      hardwareid            count
status
1   12345zzzzz       A12345           <null>               1
t

Where it says t for status I wanted it to say available but mean true for
boolean, but I don't know how to do that. Thanks to all for help.


If the field has to be a boolean, then alias it on the select:

select case when status = 't' then 'available' else 'unavailable' end from club_Games

otherwise make status a text field and just enter 'available' or 'unavailable'

--
Adrian Klaver
adrian.klaver@xxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux