SQL Server Performance Forum – Threads Archive
please….. I want code
I have clients table that contain on the gender fieldAnd this field contain the id of gender 1 and 2 but I have another table(gender1)
Which contain the id of gender and the name of gender male and female The problem I want transact statement that display all the fields in
Clients table but the gender field display the name of gender in the
Gender1 table not the id of gender which is saved in the clients table
Look at INNER JOIN in SQL Books On Line.
And tell the person designing the database that they are idiots. MeanOldDBA
[email protected] When life gives you a lemon, fire the DBA.
Hi derrick be cool. Hi B5CSE,
Is there a need to make another table to store two records for gender.
U should have inserted gender name directly into client table. Anyways u can try this.
Select c.clname,g.gname from
client c inner join gender g on
c.gid=g.gid
Strange indeed,
You can do this without joining the tables Select c.clname,Gender =
case When GenderID = 1 then ‘Male’ else ‘Female’ end
from
client
quote:Originally posted by B5CSE
I have clients table that contain on the gender field
And this field contain the id of gender 1 and 2 but I have another table(gender1)
Which contain the id of gender and the name of gender male and female The problem I want transact statement that display all the fields in
Clients table but the gender field display the name of gender in the
Gender1 table not the id of gender which is saved in the clients table
And this field contain the id of gender 1 and 2 but I have another table(gender1)
Which contain the id of gender and the name of gender male and female The problem I want transact statement that display all the fields in
Clients table but the gender field display the name of gender in the
Gender1 table not the id of gender which is saved in the clients table
quote:U should have inserted gender name directly into client table.
No, he shouldn’t.
[<img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
[:0]Gender field has few predefined values then why he should not normalize the database.<br />I dont c any necessity for that extra gender table.[<img src=’/community/emoticons/emotion-11.gif’ alt=’8)’ />]<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by mmarovic</i><br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">U should have inserted gender name directly into client table.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">No, he shouldn’t.<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />
quote:Select c.clname,Gender =
case When GenderID = 1 then ‘Male’ else ‘Female’ end
from
client
That is solution I support. Keep GenderId as a bit column . There is no need for lookup table. Even better return from sql genderID and interpret data on midle tier or client. Puting GenderName in Client table may be acceptable if table is small enough and not updated frequently but it is not realy necessary.
case When GenderID = 1 then ‘Male’ else ‘Female’ end
from
client
derrick, <br />I know what M and F stand for<br />WHat are the others <br />[<img src=’/community/emoticons/emotion-11.gif’ alt=’8)’ />]<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by derrickleggett</i><br /><br />[<img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
adding more to it[<img src=’/community/emoticons/emotion-2.gif’ alt=’
![Big Grin :D :D](styles/default/xenforo/smilies/biggrin.png)
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
I guess that is not a gender it is a behaviour [<img src=’/community/emoticons/emotion-4.gif’ alt=’
![Stick Out Tongue :p :p](styles/default/xenforo/smilies/tongue.png)
M-Male (definitely gender)
F-Female (definitely gender)
H-Hermathrodite (definitely gender)
T-Transgender (definitely gender)
G-Gay (orientation)
L-Lesbian (orientation)
N-Neuter (this one could hurt. Gender????) A you need is M or F. You don’t need a seperate table for that. If you see a column with M and F values called gender and you can’t figure it out, you shouldn’t be a DBA, programmer, or any profession requiring thinking. That’s normalized to stupidity. If you want to have a drop-down box populated by a lookup table, then fine. Normalization is absolutely critical and extremely important. Taking it to that level though is just normalizing ad nauseam. MeanOldDBA
[email protected] When life gives you a lemon, fire the DBA.
Have a bit for gender, where 1 = true and 0 = false. For the column title, call it ‘Superior’ and have 1 indicate ‘Male’! (light the touchpaper and stand back…) Small Businesses
www.matiogi.com
]]>