Solved

What is the problem with this query

Posted on 2008-10-27
8
173 Views
Last Modified: 2012-05-05
i am getting syntax error near "where" !!
select table1.*,[table2].*,table3.* from (table1 where table1.coulumn1='value' LEFT JOIN table1.column1=[table2].column1) LEFT JOIN table3 ON table1.column1=table3.column1)

Open in new window

0
Comment
Question by:jaisonshereen
8 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
Comment Utility
There is something wrong with the parantheses. Try removing them.
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 200 total points
Comment Utility
parentheses did not belong
WHERE needs to follow the FROM clause (which includes any JOIN's)

select table1.*,[table2].*,table3.* from 

table1 LEFT JOIN table1.column1=[table2].column1) LEFT JOIN table3 ON table1.column1=table3.column1

where table1.coulumn1='value' 

Open in new window

0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 150 total points
Comment Utility
this will work better:
select table1.*,[table2].*,table3.* 
from table1 
LEFT JOIN table3 ON table1.column1=table3.column1
LEFT JOIN table2 ON table1.column1=[table2].column1
where table1.coulumn1='value'

Open in new window

0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 150 total points
Comment Utility
try:
SELECT 
	table1.*,table2.*,table3.* 
FROM 
	table1,table2,table3
WHERE
	table1.column1=table2.column1
AND
	table1.column1=table3.column1
AND
	table1.column1='value' 

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
I agree with Angel Eyes and Daniel.  Nothing personal, Hielo.

I personally like to specify the join types in the FROM clause where I am doing the joins so I don't spend time troubleshooting why the data is coming back funny because the system decides to do an inner join here instead of a left join which have distinctly different purposes especially when dealling with 3 tables.

My humble opinion anyway.
0
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
Future editions of SQL Server (past 2000 I believe) do not allow outer joins through the non-ANSI =* syntax.
0
 
LVL 32

Expert Comment

by:Daniel Wilson
Comment Utility
>>this will work better:

Yes, it will.  I failed to fix the JOIN syntax.  Working too fast ... trying to beat you guys to the post! :-)
0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
We knew what you meant. LOL and I know -- posted one yesterday without the FROM clause but showed the right select, where, and group by which answered question but still...
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Date Range Syntax Access 2003 10 44
MS SQL Backup 24 69
Help in Understanding a SQL Query 7 24
Distinct values from two tables 14 16
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now