p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: help with sql query


Message #1 by dont worry <aspmailbox@y...> on Thu, 7 Mar 2002 10:15:30 -0800 (PST)
If I understand what you are trying to do, you will need to include the
table containing the detailName and detailValue twice in your join.
Once to extract the height value into it's own column and once to
extract the IQ value into it's column.

See the SQL below, let me know if this is not what you were trying to
do.

SELECT
	b.detailValue as HEIGHT,
	a.userID as ID,
	a.userName as NAME,
	c.detalValue as IQ
FROM
	<table_name1> a
	INNER JOIN <table_name2> b on a.CUSTID = b.CUSTID
	INNER JOIN <table_name2> c on a.CUSTID = c.CUSTID
WHERE
	b.detailName = 'height'
	AND
	c.detailName = 'IQ'

-jd

-----Original Message-----
From: dont worry [mailto:aspmailbox@y...] 
Sent: Thursday, March 07, 2002 11:16 AM
To: Code Clinic
Subject: [proasp_codeclinic] help with sql query

I have a two tables.
A)has userId and userName
B)has userId, detailId, detailName, detailValue
____________________________________
So with a inner join I could extract.
userID  userName
1          DW
++++++
detailName    detailValue
Height           5/8
Weight           165
IQ                -1

I want to create a query that would allow me to group
with in the same table.  Or would give me IQ in each
height.

Thanks,

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

$subst('Email.Unsub').


  Return to Index