BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MySQL - Unknown table 'clientdetails' in where clause

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
nix
Guest





PostPosted: Wed Dec 10, 2003 12:23 am    Post subject: MySQL - Unknown table 'clientdetails' in where clause Reply with quote



Hi, I want run a select statement that retrieves information, based on a few
requirements...

============================
select orderdetails.*, clientdetails.ClientStatus
from orderdetails LEFT JOIN clientdetails ON (orderdetails.ClientID =
clientdetails.ClientID)
where LastBilled < 37956
AND BillingCommencement < 37965.08
AND (Product_FIRSTGEAR = '0' OR Product_SECONDGEAR = '0' OR
Product_THIRDGEAR = '0' OR Product_FOURTHGEAR = '0') AND (OrderStatus
='ACTIVATED')
============================

The above statement works fine, however, when I add the condition of another
table......

==============================
select orderdetails.*, clientdetails.ClientStatus
from orderdetails LEFT JOIN clientdetails ON (orderdetails.ClientID =
clientdetails.ClientID)
where LastBilled < 37956
AND BillingCommencement < 37965.08
AND (Product_FIRSTGEAR = '0' OR Product_SECONDGEAR = '0' OR
Product_THIRDGEAR = '0' OR Product_FOURTHGEAR = '0') AND (OrderStatus
='ACTIVATED' AND clientdetails.ClientStatus = 'APPROVED FOR PAYMENTS')
==============================

it gives me the error " Unkown table 'clientdetails' in where clause". I am
using D7 Pro, MySQL on Win XP Pro SP2... what am I doing wrong?????

Thanx in adv.
Karl


Back to top
Dell Stinnett
Guest





PostPosted: Wed Dec 10, 2003 2:47 pm    Post subject: Re: MySQL - Unknown table 'clientdetails' in where clause Reply with quote



Why are you using a Left Join? The Left Join means that you'll get all
records from OrderDetails regardless of whether there's a corresponding
record in ClientDetails. By setting a where condition that includes the
ClientDetails table, your Left Join isn't going to work right. I would do
something like this:

select orderdetails.*, clientdetails.ClientStatus
from orderdetails,
clientdetails
where (orderdetails.ClientID = clientdetails.ClientID)
AND LastBilled < 37956
AND BillingCommencement < 37965.08
AND (Product_FIRSTGEAR = '0' OR Product_SECONDGEAR = '0' OR
Product_THIRDGEAR = '0' OR Product_FOURTHGEAR = '0') AND (OrderStatus
='ACTIVATED')

-Dell



Back to top
baloonatic@hotmail.com
Guest





PostPosted: Wed Dec 10, 2003 7:33 pm    Post subject: Re: MySQL - Unknown table 'clientdetails' in where clause Reply with quote



On Wed, 10 Dec 2003 02:23:03 +0200, "nix" <nimand (AT) nix (DOT) com> wrote:

Quote:
Select * From
(
select orderdetails.*, clientdetails.ClientStatus
from orderdetails LEFT JOIN clientdetails ON (orderdetails.ClientID =
clientdetails.ClientID)
where LastBilled < 37956
AND BillingCommencement < 37965.08
AND (Product_FIRSTGEAR = '0' OR Product_SECONDGEAR = '0' OR
Product_THIRDGEAR = '0' OR Product_FOURTHGEAR = '0') AND (OrderStatus
='ACTIVATED')
) asuitablealias WHERE asuitablealias.ClientStatus = 'APPROVED FOR

PAYMENTS'

might achieve the desired effect. From the error it's jibbing because
clientdetails is used in the where clause but not in the from clause
as it only appears in the join syntax.

Bit of a pain though is n't it.

Come back SQL Server all is relative though of course not free

Back to top
nix
Guest





PostPosted: Thu Dec 11, 2003 8:32 am    Post subject: Re: MySQL - Unknown table 'clientdetails' in where clause Reply with quote

Thanx I'll give it a try...

Karl

"Dell Stinnett" <dell.stinnett> wrote

Quote:
Why are you using a Left Join? The Left Join means that you'll get all
records from OrderDetails regardless of whether there's a corresponding
record in ClientDetails. By setting a where condition that includes the
ClientDetails table, your Left Join isn't going to work right. I would do
something like this:

select orderdetails.*, clientdetails.ClientStatus
from orderdetails,
clientdetails
where (orderdetails.ClientID = clientdetails.ClientID)
AND LastBilled < 37956
AND BillingCommencement < 37965.08
AND (Product_FIRSTGEAR = '0' OR Product_SECONDGEAR = '0' OR
Product_THIRDGEAR = '0' OR Product_FOURTHGEAR = '0') AND (OrderStatus
='ACTIVATED')

-Dell






Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.