SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 17th, 2004, 09:56 AM
C3P0's Avatar
C3P0 C3P0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 302 C3P0 User rank is Private First Class (20 - 50 Reputation Level)C3P0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 38 m 27 sec
Reputation Power: 7
LEFT JOIN with odbc & php

I'm trying a simple LEFT JOIN on two tables, via odbc connection. I'm connecting to SQL Server.

PHP Code:
 SELECT 
    Cust
.LastName AS namelast
    
Cust.FirstName AS namefirst,
    
Cust.MiddleInitial AS namemiddle
    
Cust.SortName AS namesort
    
Cust.SpecialityCode AS speccode
    
Cust.CreationDate AS creationdate
    
Cust.SubId AS subid
    
Cust.Filler AS filler,
    
Office.LastPurchaseDate
FROM
    Cust
    LEFT JOIN Office ON Office
.FacilityId Cust.FacilityId
WHERE 
    Office
.LastPurchaseDate'20040217' 


This yeilds the following error:

PHP Code:
 Warning:  SQL error: [Pervasive Software][ODBC Interface][Pervasive Software SQL Engine]The syntax in the WHERE clause is invalid., SQL state 37000 in SQLExecDirect in blahblah...

[
Pervasive Software][ODBC Interface][Pervasive Software SQL Engine]The syntax in the WHERE clause is invalid


Since I pulled the WHERE clause from a working, known-good query, I assume the error is referring to my LEFT JOIN? I don't know where to look for documentation on how to construct a simple LEFT JOIN in odbc.. I tried googling but I didn't see anything like mysql.org where the doc is easily accessed.

Any help is most appreciated.

Last edited by C3P0 : May 17th, 2004 at 02:12 PM.

Reply With Quote
  #2  
Old May 17th, 2004, 01:45 PM
aclarkzx2 aclarkzx2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 aclarkzx2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try Left Outer Join

Reply With Quote
  #3  
Old May 17th, 2004, 02:21 PM
C3P0's Avatar
C3P0 C3P0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 302 C3P0 User rank is Private First Class (20 - 50 Reputation Level)C3P0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 38 m 27 sec
Reputation Power: 7
When you wrote "try" were you sure it was going to work, or simply guessing?

Reply With Quote
  #4  
Old May 17th, 2004, 02:27 PM
C3P0's Avatar
C3P0 C3P0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 302 C3P0 User rank is Private First Class (20 - 50 Reputation Level)C3P0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 38 m 27 sec
Reputation Power: 7
Yes that does in fact work. The correct syntax, in case anyone needs it, is:

PHP Code:
 SELECT 
    table_1
.idtable_2.name 
FROM
    
{oj table_1 LEFT OUTER JOIN table_2 ON table_2.id table_1.id }
WHERE 
    table_1
.id 'abc123' 


Thank you.

Reply With Quote
  #5  
Old May 17th, 2004, 02:31 PM
aclarkzx2 aclarkzx2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 aclarkzx2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Left outer join should work

Reply With Quote
  #6  
Old May 22nd, 2004, 09:21 PM
dploftus@hotmai dploftus@hotmai is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 dploftus@hotmai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can not use WHERE with LEFT JOIN

Reply With Quote
  #7  
Old May 23rd, 2004, 08:49 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Quote:
You can not use WHERE with LEFT JOIN


You most certainly can.

Reply With Quote
  #8  
Old May 24th, 2004, 09:01 AM
C3P0's Avatar
C3P0 C3P0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 302 C3P0 User rank is Private First Class (20 - 50 Reputation Level)C3P0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 38 m 27 sec
Reputation Power: 7
Quote:
Originally Posted by dploftus@hotmai
You can not use WHERE with LEFT JOIN

Odd, because the query I pasted right above your post works perfectly. Maybe you don't know what you're talking about?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > LEFT JOIN with odbc & php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway