If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > inner join ignores where clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-07, 07:36
Derick Salls Derick Salls is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
inner join ignores where clause

Using Pervasive SQL v8, this query ignores the WHERE clause. If I remove the INNER JOIN, the query works correctly. How do I do this query with the INNER JOIN?

Query = Select arlinh.documentnumber, arlinh.locationkey, arlinh.revenueacctkey, arlinh.shipdate, inloc.itemclasskey from arlinh INNER JOIN inloc ON (arlinh.itemkey = inloc.itemkey); WHERE ((arlinh.shipdate BETWEEN '2007-01-01' AND '2007-01-08') AND (arlinh.revenueacctkey BETWEEN '40000000' AND '4999Z999'))

With the INNER JOIN, all the records in the database are in the resulting recordset; while, without it, only the records defined by the WHERE clause are in the resulting recordset.
Reply With Quote
  #2 (permalink)  
Old 03-13-07, 08:29
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
A couple of questions:
1. where are you running the query?
2. Is "Select arlinh.documentnumber, arlinh.locationkey, arlinh.revenueacctkey, arlinh.shipdate, inloc.itemclasskey from arlinh INNER JOIN inloc ON (arlinh.itemkey = inloc.itemkey); WHERE ((arlinh.shipdate BETWEEN '2007-01-01' AND '2007-01-08') AND (arlinh.revenueacctkey BETWEEN '40000000' AND '4999Z999'))" the exact query?

If number 2 is the correct query, what happens if you remove the semicolon (";") from the query so it looks like:
Select arlinh.documentnumber, arlinh.locationkey, arlinh.revenueacctkey, arlinh.shipdate, inloc.itemclasskey from arlinh INNER JOIN inloc ON (arlinh.itemkey = inloc.itemkey) WHERE ((arlinh.shipdate BETWEEN '2007-01-01' AND '2007-01-08') AND (arlinh.revenueacctkey BETWEEN '40000000' AND '4999Z999'))
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 03-13-07, 08:47
Derick Salls Derick Salls is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
inner join ignores where clause

1. I am running the the query in VB6-ADO
2. Yes, that is the exact query

I removed the semicolon and the query worked as it was suppossed to. I changed the WHERE dates and again, it worked correctly. I added some more fields and again, it worked correctly. Thanks.
Reply With Quote
  #4 (permalink)  
Old 03-13-07, 13:57
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
No worries. The semicolon is a statement separator in PSQL.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #5 (permalink)  
Old 03-13-07, 14:04
Derick Salls Derick Salls is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Does that mean that I could (or should) have placed a semicolon at the end of the complete sql query?
Reply With Quote
  #6 (permalink)  
Old 03-13-07, 14:14
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
You could but it's not required unless you've got multiple statements.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #7 (permalink)  
Old 03-13-07, 14:34
Derick Salls Derick Salls is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
That's good to know. Thanks!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On