I have a table called products. it holds information about all products that we sell. To pull up a specific suppliers products, i do an inner join to another table that holds the supplierid. now i want to add products based on that same supplierid that is stored on the second table.
Sql insert with inner join
Collapse
X
-
-
This question is more suitable to DB forum. Moreover, you have not properly described your problem in detail. Please share the table definitions here. Skeleton for inner join is:
Hope this helps.Code:SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name
-
I know how to make a regular join. I am not trying to make a regular join. I have a table called products. I have another table suppliers. the products table does not have a supplierid. what i want to do, is create a new product in the products table connecting it to the supplierID in the suppliers table.Comment
-
-
Are you asking how to link a product in the Products table to a supplier in the Suppliers table but without having a field in the Products table that handles the join?Originally posted by readbananareadbanana: I have a table called products. I have another table suppliers. the products table does not have a supplierid. what i want to do, is create a new product in the products table connecting it to the supplierID in the suppliers table.
If so, I'm afraid the answer is that it's not possible. That's the whole point of the field being required in the first place. Joins are done using PK/FK matching. That is Primary Key/Foreign Key matching. Technically any Unique Key can be used in place of a PK, but you need an FK to link to something.
If this isn't what you're asking, could I ask you to explain clearly what that is. It's a bit difficult helping without a question that makes sense. Maybe take a few minutes of your time to ensure it can be understood.Comment
-
no, i have a field that can join them both - the connect through the productid its more that i'm trying to add a product to the product table and i need to link it to the supplierid in the the suppliers tableComment
-
There still seems to be some sort of gulf in understanding here. As you provide extremely little in the way of information it's hard for me to determine exactly what it is you're failing to grasp. Hence my request that you give a little more consideration to your reply.
If you have a link already then why do you need further help? If, as I suspect, that link can only identify the product from the supplier, as opposed to the other way around as you seem to require, then you're back where I left you earlier, which is requiring a supplier reference in your product table.
Unless you make the position clearer with your next post I can't imagine I can help you any further.Comment
-
-
Comment