0

I have two tables. In the first one there is a column called id. I want to select some of these IDs, and to choose from the other table the rows that have these IDs. How do I do that?

4

2 に答える 2

1

You need to learn SQL joins.

SELECT SecondTable.*
FROM SecondTable 
INNER JOIN FirstTable ON (FirstTable.ID = SecondTable.ID)
WHERE FirstTable.SomeField = 'Something Else'
于 2012-05-01T09:49:56.263 に答える
1

Here is a good link to get you started

Inner Joins

Basically for your example you would use something like

SELECT table1.id, table1.value, table2.value
FROM table1
INNER JOIN table2
ON table1.id=table2.id
于 2012-05-01T09:58:22.137 に答える