2

I'm using SQL-server. I have 2 tables: Items (Id, OwnerId, ItemName) and Owners (Id, OwnerName)

It should select something like (connect data from 2 tables):

OwnerName | Items.Id | ItemName

I've tried:

SELECT OwnerName, Items.Id, ItemName
FROM Items, Owners

But It not working, have you ideas?

1
  • You probably need third table containing ids of both tables at least as relationship seem many-to- many Commented Mar 13, 2015 at 12:13

1 Answer 1

0

You should JOIN tables.

SELECT o.OwnerName, i.Id, i.ItemName
FROM Items AS i
JOIN Owners AS o 
ON o.Id = i.OwnerId
Sign up to request clarification or add additional context in comments.

2 Comments

Or it could be: on o.Id = I.Id depending on your table structure
I think It's good. Id from Owners table and OwnerId from Items table. Look at tables structure in question.