Sami,

Something like this came up a while back. Try:

Select t1.ServiceType from Services t1, BillCategory t2 Whe 
t1.ServiceType = t2.BillCategory

This seems to be more predictable than subselects.

Here's something that's got me stumped. How would you convert a 
"not in" subselect to an aliased statement as above?

Ben Petersen



On 31 May 2002, at 13:09, Sami Aaron wrote:

> Ok, I've had a head cold this last week but it really shouldn't have
> affected my brain... I need someone to tell me if this should work:
> 
> I have two tables in a database,
> 
> ServiceTypes, containing a column, ServiceType (TEXT 50) that includes this
> list:
>     Initial Assessment
>     Lesson
>     Self-Practice
>     Typing Tutorial
>     Cancellation
> 
> and
> 
> BillCategories, with a column, BillCategory (TEXT 20) that includes this
> list:
>     Supplies
>     OtherExpenses
>     Self-Practice
>     Typing Tutorial
>     Mileage
> 
> If I issue the statement:
> SELECT BillCategory FROM BillCategories WHERE BillCategory IN (SELECT
> ServiceType FROM ServiceTypes)
> 
> It correctly returns the values,
>     Self-Practice
>     Typing Tutorial
> 
> BUT, if I do the reverse of this statement and type:
> SELECT ServiceType FROM ServiceTypes WHERE ServiceType IN (SELECT
> BillCategory FROM BillCategories)
> 
> I get a "No Rows Exist ..." message.
> 
> If I refine it and type:
> SELECT ServiceType FROM ServiceTypes WHERE ServiceType = 'self-practice' AND
> ServiceType IN (SELECT BillCategory FROM BillCategories)
> It correctly returns 'Self-Practice'
> 
> Apparently it's the difference in data length - It works if I type:
> SELECT ServiceType FROM ServiceTypes WHERE (SGET(ServiceType,20,1)) IN
> (SELECT BillCategory FROM BillCategories)
> 
> It seems to me that "Self-Practice" = "Self-Practice" regardless of the size
> of the data field.
> 
> Sami
> 
> 
> 
> -----------------------------------------------------------
> Sami Aaron
> Software Management Specialists
> 19312 W 63rd Terr
> Shawnee KS  66218
> 913-915-1971
> http://www.softwaremgmt.com
> 
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
> 
> 
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: INTRO rbase-l
> ================================================
> TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
> In the message body, put just two words: UNSUBSCRIBE rbase-l
> ================================================
> TO SEARCH ARCHIVES:
> http://www.mail-archive.com/rbase-l%40sonetmail.com/
> 


================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/

Reply via email to