469,927 Members | 1,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Query

Hi;

Can someone help me forming the following query.

I have a table with name, value, environment as column names. And the
data looks like

JMSHost prdIPAddress production
JMSHost devIPAddress development
JMSPort Portnumber production

As you can see, the config table contain the values for different
environments. I would like to select all the "production" values first
and overwrite with an specific environment value. For eg, if its
"development" I would like to get the data of rows 2 and 3.

I hope this is clear. I appreciate your help on this.

Thanks
Nov 12 '05 #1
4 1575
"Prakash" <ve***********@hotmail.com> wrote in message
news:78**************************@posting.google.c om...
Hi;

Can someone help me forming the following query.

I have a table with name, value, environment as column names. And the
data looks like

JMSHost prdIPAddress production
JMSHost devIPAddress development
JMSPort Portnumber production

As you can see, the config table contain the values for different
environments. I would like to select all the "production" values first
and overwrite with an specific environment value. For eg, if its
"development" I would like to get the data of rows 2 and 3.

I hope this is clear. I appreciate your help on this.

Thanks


Not clear to me. Rows 2 and 3 are development and production.
Nov 12 '05 #2
yes. 2 and 3 are dev and production. Since there are 2 rows for
"JMSHost" I want to take only one, which is "dev". So I want the
output to show JMSHost for "dev" (overwritten with JMSHost of
production) and JMSPort of production (since there are no JMSPort for
dev).

Thanks
Nov 12 '05 #3
ve***********@hotmail.com (Prakash) wrote in message news:<78**************************@posting.google. com>...
yes. 2 and 3 are dev and production. Since there are 2 rows for
"JMSHost" I want to take only one, which is "dev". So I want the
output to show JMSHost for "dev" (overwritten with JMSHost of
production) and JMSPort of production (since there are no JMSPort for
dev).

Thanks

How about this?

SELECT name, value, environment
FROM your_table X
WHERE environment = 'development'
OR environment = 'production'
AND
NOT EXISTS
(SELECT *
FROM your_table Y
WHERE Y.name = X.name
AND Y.environment = 'development'
)
;
Nov 12 '05 #4
Great. Thanks !!
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.