ilc Posted February 22, 2019 Share Posted February 22, 2019 I am trying to join data from two views. The first has a column "Type". I need to insert data from the second but identify it as a certain "Type". I have performed an Outer Join. How can I insert type for the data in the second view. The "Type" field in the first view is identifying whether the inventory is on hand or inbound. I want to identify the data from the second view as Type- Vendor Contract. My columns are: 1st view (Inventory on Hand/Inbound) - Item Code, Desc, Qty, Type 2nd view (Inventory Contracted with Vendors)- U_Item Code, Desc, Qty Link to comment Share on other sites More sharing options...
Funce Posted February 24, 2019 Share Posted February 24, 2019 Is it necessary to have them in separate tables? This seems like the exact trouble you'd run if they're separate. You might want to look at `CASE` statements, and using `EXISTS`. If you really want to go down this route. I tried looking at these questions: https://stackoverflow.com/questions/4076098/how-to-select-rows-with-no-matching-entry-in-another-table/36694478#36694478 https://stackoverflow.com/questions/63447/how-do-i-perform-an-if-then-in-an-sql-select Link to comment Share on other sites More sharing options...
justsomeguy Posted February 25, 2019 Share Posted February 25, 2019 If everything is the same type you can just select a scalar value: SELECT 'Vendor Contract' as `type`, item_code, desc, qty... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now