Solved

Problem with Query....

Posted on 2008-10-15
4
221 Views
Last Modified: 2011-09-20
Hi there,

Simple query that I cant get to run, this is the query:

SELECT m.*, mt.restricts, b.Module
FROM mat_trnkld m, matprt_trnkld mt LEFT JOIN BOM b
ON m.PartNo = b.partnumber
WHERE m.PartNo = mt.PartNo
AND m.SubProd = '50'

and I'm getting this error:

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "m.PartNo" could not be bound.


Thanks,

Stelly
0
Comment
Question by:stellyuk
4 Comments
 
LVL 5

Accepted Solution

by:
jfmador earned 250 total points
ID: 22727769
Define your join between mat_trnkld and matprt_trnkld before using the left join

Try this
SELECT m.*, mt.restricts, b.Module
FROM mat_trnkld m INNER JOIN matprt_trnkld mt on m.PartNo = mt.PartNo
LEFT JOIN BOM b ON m.PartNo = b.partnumber
WHERE m.SubProd = '50'
0
 
LVL 2

Assisted Solution

by:Deepika_Rastogi
Deepika_Rastogi earned 250 total points
ID: 22728139
Hi

As matprt_trnkld and BOM are joined with each other we can't use mat_trnkld in the bound.
Instead in the bound condition mention the tables that are joined.
so try this

SELECT m.*, mt.restricts, b.Module
FROM mat_trnkld m, matprt_trnkld mt LEFT JOIN BOM b
ON mt.PartNo = b.partnumber
WHERE m.PartNo = mt.PartNo
AND m.SubProd = '50'

Hope you find the solution.
Deepika

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
t-sql Joining Issue 10 37
kill process lock Sql server 9 47
sql help 8 55
T-SQL Default value in Select? 5 26
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

776 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