tags:

views:

51

answers:

2

I have two tables:

A:
[ date,
 step,
 status,
 ... ]

B:
[ date,
  step,
  name,
  ... ]

I want to get result in form of

[date, step, name]

based on status parameter. I can easly get data from table A using following query:

Select date, step From A Where status='1'

and the result would be like:

1. 2010-09-12; 5
2. 2010-09-13; 3
...

but i dont know how to use it to find names from table B corresponding to those records.

Thanks for any help.

+1  A: 
Select B.Name
From A
Inner Join B
  On A.date = B.date
  And A.step = B.step
Where A.status = '1'
Geert Immerzeel
Thought i Post a link to joins because it seems he doesn't know what those are: http://www.w3schools.com/Sql/sql_join.asp
Emerion
Thanks for link. I know basic of join but i didnt know that you can do it based on more than one condition.
zgorawski
+1  A: 

You need to join the two tables. From your question i immagine that you want to do something like this:

Select a.date, a.step, b.name  
From A a, B b
Where a.status='1' and a.date = b.date and a.step = b.step

You can read mor on joining table in Wikipedia or this description of sql joins

ladi