Unix Technical Forum

Query Question

This is a discussion on Query Question within the SQL Server forums, part of the Microsoft SQL Server category; --> I have the following tables: Table Name: GL_CODE_DESC Field Names: GLCODE, GLDESC Table Name: GL_SVC_CODES Field Names: GLCODE, SVCCODE ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 02:55 PM
Mike
 
Posts: n/a
Default Query Question

I have the following tables:

Table Name: GL_CODE_DESC
Field Names: GLCODE, GLDESC

Table Name: GL_SVC_CODES
Field Names: GLCODE, SVCCODE

What I would like is a query that pulls the distinct rows from the table
GL_CODE_DESC but only where the GLCODES are equal between the two tables.

How would I do this?

Thanks in advance!!

Mike


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 02:55 PM
MC
 
Posts: n/a
Default Re: Query Question

Something like this?

select distinct gd.GLCODE, gd.GLDESC
from
GL_CODE_DESC gd
inner join GL_SVC_CODES gs on gd.GLCODES = gs.GLCODES

I dont really understand the req about GLCODES being equal but this should
help you out....
MC


"Mike" <noway@forgetit.com> wrote in message
news:GUmef.4$rq3.0@newssvr19.news.prodigy.com...
>I have the following tables:
>
> Table Name: GL_CODE_DESC
> Field Names: GLCODE, GLDESC
>
> Table Name: GL_SVC_CODES
> Field Names: GLCODE, SVCCODE
>
> What I would like is a query that pulls the distinct rows from the table
> GL_CODE_DESC but only where the GLCODES are equal between the two tables.
>
> How would I do this?
>
> Thanks in advance!!
>
> Mike
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 02:55 PM
Mike
 
Posts: n/a
Default Re: Query Question

I figured it out. I am idiot today.

I used the following:
SELECT T1.* FROM T1, T2 WHERE T1.C1 = T2.C1

Thanks,
Mike

"MC" <marko_culo#@#yahoo#.#com#> wrote in message
news:dlcuce$eaj$1@magcargo.vodatel.hr...
> Something like this?
>
> select distinct gd.GLCODE, gd.GLDESC
> from
> GL_CODE_DESC gd
> inner join GL_SVC_CODES gs on gd.GLCODES = gs.GLCODES
>
> I dont really understand the req about GLCODES being equal but this should
> help you out....
> MC
>
>
> "Mike" <noway@forgetit.com> wrote in message
> news:GUmef.4$rq3.0@newssvr19.news.prodigy.com...
>>I have the following tables:
>>
>> Table Name: GL_CODE_DESC
>> Field Names: GLCODE, GLDESC
>>
>> Table Name: GL_SVC_CODES
>> Field Names: GLCODE, SVCCODE
>>
>> What I would like is a query that pulls the distinct rows from the table
>> GL_CODE_DESC but only where the GLCODES are equal between the two tables.
>>
>> How would I do this?
>>
>> Thanks in advance!!
>>
>> Mike
>>

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 02:55 PM
MC
 
Posts: n/a
Default Re: Query Question

Uhh, you will not get distinct rows with this query. You're missing the
'distinct' in the select part..

MC

"Mike" <noway@forgetit.com> wrote in message
news:9wnef.172$4o7.80@newssvr24.news.prodigy.net.. .
>I figured it out. I am idiot today.
>
> I used the following:
> SELECT T1.* FROM T1, T2 WHERE T1.C1 = T2.C1
>
> Thanks,
> Mike
>
> "MC" <marko_culo#@#yahoo#.#com#> wrote in message
> news:dlcuce$eaj$1@magcargo.vodatel.hr...
>> Something like this?
>>
>> select distinct gd.GLCODE, gd.GLDESC
>> from
>> GL_CODE_DESC gd
>> inner join GL_SVC_CODES gs on gd.GLCODES = gs.GLCODES
>>
>> I dont really understand the req about GLCODES being equal but this
>> should help you out....
>> MC
>>
>>
>> "Mike" <noway@forgetit.com> wrote in message
>> news:GUmef.4$rq3.0@newssvr19.news.prodigy.com...
>>>I have the following tables:
>>>
>>> Table Name: GL_CODE_DESC
>>> Field Names: GLCODE, GLDESC
>>>
>>> Table Name: GL_SVC_CODES
>>> Field Names: GLCODE, SVCCODE
>>>
>>> What I would like is a query that pulls the distinct rows from the table
>>> GL_CODE_DESC but only where the GLCODES are equal between the two
>>> tables.
>>>
>>> How would I do this?
>>>
>>> Thanks in advance!!
>>>
>>> Mike
>>>

>>
>>

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:38 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com