By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

Sql insert with inner join

P: 37
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.
Jul 15 '10 #1
Share this Question
Share on Google+
9 Replies


Meetee
Expert Mod 100+
P: 931
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:
Expand|Select|Wrap|Line Numbers
  1. SELECT column_name(s)
  2. FROM table_name1
  3. INNER JOIN table_name2
  4. ON table_name1.column_name=table_name2.column_name
Hope this helps.
Jul 16 '10 #2

P: 37
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.
Jul 16 '10 #3

NeoPa
Expert Mod 15k+
P: 31,768
We'd like to help, but you haven't actually asked a question.

Welcome to Bytes!
Jul 16 '10 #4

P: 37
whatever i realize what my problem is thanx anyway
Jul 16 '10 #5

NeoPa
Expert Mod 15k+
P: 31,768
readbanana: 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.
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?

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.
Jul 16 '10 #6

P: 37
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 table
Jul 16 '10 #7

NeoPa
Expert Mod 15k+
P: 31,768
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.
Jul 16 '10 #8

P: 37
ok. lets forget this. thanx anyway
Jul 16 '10 #9

NeoPa
Expert Mod 15k+
P: 31,768
New question from the OP was moved to it's own thread (Delete Word in Field).
Jul 16 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.