Note that there are some explanatory texts on larger screens.

plurals
  1. POHave a SQL Query that needs to match a number from user input to multiple columns then to column on other table
    primarykey
    data
    text
    <p>I have a query that takes a user uploaded csv and matches the number on my sql table. That is listed below. It works fine but i need another query to do something similar.</p> <p>I now need a query that selects (not updates). This query will be used on my aspx page. User will enter a part number and i then display my companies matching part number along with all the other details. the flow is shown in the picture attached.</p> <p>I have tried many things trying to get this to work. i have researched quite a bit and just not versed in sql enough to put this together.</p> <p>This is the query that works when user uploads their csv file</p> <pre><code>UPDATE imports SET imports.AMIPartNumber = coalesce(AMIA.Item,AMIB.Item,AMIC.Item,AMID.Item,AMIE.Item), Imports.AMIDescription = coalesce(AMIA.Description,AMIB.Description,AMIC.Description,AMID.Description,AMIE.Description) FROM imports as I LEFT JOIN JD as JDA ON I.OEMPartNumber = JDA.OEMPartNumber LEFT JOIN amipartnumbers as AMIA ON JDA.OEMPartNumber = AMIA.OEMItem LEFT JOIN JD as JDB ON I.OEMPartNumber = JDB.OEMSubNumber LEFT JOIN amipartnumbers as AMIB ON JDB.OEMSubNumber = AMIB.OEMItem LEFT JOIN JD as JDC ON I.OEMPartNumber = JDC.OEMSubNumber2 LEFT JOIN amipartnumbers as AMIC ON JDB.OEMSubNumber2 = AMIC.OEMItem LEFT JOIN JD as JDD ON I.OEMPartNumber = JDD.OEMSubNumber3 LEFT JOIN amipartnumbers as AMID ON JDB.OEMSubNumber2 = AMID.OEMItem LEFT JOIN JD as JDE ON I.OEMPartNumber = JDE.OEMSubNumber4 LEFT JOIN amipartnumbers as AMIE ON JDB.OEMSubNumber2 = AMIE.OEMItem ; select * from imports </code></pre> <p>This is the flow of what im trying to do (fyi AMI in picture is amipartnumbers in query above) <img src="https://i.stack.imgur.com/UCIRw.jpg" alt="flow"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload