Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create virual column with SQL

Status
Not open for further replies.

Pieterrr

Technical User
Joined
Jul 5, 2008
Messages
3
Location
NL
Hello,

I want to create a virtual column in SQL with two values.

Like this:


gender
------
male
female


I can create a column with one value with the statement:

SELECT "male" AS gender

Can someone help me?

Thnx!

 
You could use a union query, though I am curious as to why you want to do this.

SELECT "male" AS gender
UNION
SELECT "female" AS gender
 
It doesn't work in Acces, is there another way to do it?

I want to make a boolean choice in my table where i can choose between male or female, the only way to do it (that i know) is to look the values up in a table. Of cource i can make a table with male and female, but then my database becomse a mesh with "unused" tables
 
Code:
SELECT TOP 1 "male" AS gender From AnyTable
UNION
SELECT Top 1 "female" AS gender From AnyTable
 
Will you be using a form to present the data? I hope so, and a form is the place to show the choice of Male or Female. You can use a combo.
 
In your form, add a combobox 'Gender', and set it to:

Row Source Type: Value List
Row Souce: Male;Female
Limit To List: Yes

Max Hugen
Australia
 
The only way "to make a boolean choice in my table where i can choose between male or female" is to have a real column/field that can be updated. You can't update a "virtual" column.


Duane
Hook'D on Access
MS Access MVP
 
Pieterrr said:
Of cource i can make a table with male and female, but then my database becomse a mesh with "unused" tables
Add some enforced relationships between your "unused" tables and the main ones and you would have what I call "data integrity".

 
Thanx Golom, with:

SELECT TOP 1 "male" AS gender From AnyTable
UNION
SELECT Top 1 "female" AS gender From AnyTable

it work's!!

I want to present the data in a form. But i also want that my table has the "right" value.

Thanx everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top