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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • You probably need third table containing ids of both tables at least as relationship seem many-to- many – Adil Mar 13 '15 at 12:13

1 Answers1

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