Skip to Content
author's profile photo Former Member
Former Member

Serial number query

Hi,

Currently I'm in my trainingperiod and I'm busy with a query to search on serialnumbers to find the needed info with it. Currently I have the next code:

SELECT DISTINCT T1.IntrSerial, T1.ItemCode, T1.ItemName, T1.WhsCode, T1.CardName, T3.CardName

FROM OSRI T1, INV1 T2, OINV T3, SRI1 T4, OCRD T5

WHERE T1.ItemCode = T2.ItemCode

AND T1.CardName = T5.CardName

AND T1.IntrSerial IN

(SELECT IntrSerial

FROM OSRI T1

WHERE T1.IntrSerial = 'm54275f00075' )

'm54275f00075' = a serial number so that's something you don't have to add. I added that line for my own help so I don't have to type a serialnumber each time. To search I use this line: WHERE T1.IntrSerial = '[%0]' FOR BROWSE

Now the problem is that he's giving me many customers when I search on a serial, while this isn't possible. There can only be 1 customer who bought the product with that serial and not like 200. So my question is how do I get the right customer who bought the product that contains the serial I'm searching for?

Any help is appreciated.

Thank you in advance!

Friendly greetings,

Martijn

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 10:49 AM

    Hi Martin,

    I would structure the query a bit differently. You don't need to (or I don't understand why you) link the OINV and INV1 tables. Also the information from OCRD are stored in the OSRI table so that link is not needed, but I left it there so you can see my join.

    SELECT T1.IntrSerial, T1.ItemCode, T1.ItemName, T1.WhsCode, T1.CardCode, T2.CardName

    FROM OSRI T1

    LEFT OUTER JOIN OCRD T2 ON T1.CardCode = T2.CardCode

    WHERE T1.IntrSerial = 'm54275f00075'

    Hope it helps,

    Adele

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 10:36 AM

    I don´t know very well the fields of the tables you use,

    but looking the query is easy to find the error. You are using tables T3 and T4 in the "from" clause but not in the "where"

    clause. So you are making a join with all the rows of that

    tables.Find the fields to relate all the tables you use in the "from" clause.

    Hope it helps 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2005 at 11:48 AM

    Woehoe drinks for everyone! 😉

    Thanks guys and Adele u gave the correct answer =)

    Now I have to find out how I will be able to see to who the "serial number" is sold to. Cause till now I only see who delivered it.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.