Reputation: 1511
I would like to select a row from 2 different tables that are relational. Would i simply put
SELECT * FROM 'said database' WHERE my condition = 'mycondition' blah blah.
Or is it some other syntactical method?
Please help. :)
All answers are greatly appreciated.
Upvotes: 3
Views: 272
Reputation: 21730
It would need to be something like:
Select * from Table1 inner Join Table2 ON Table1.field_condition_from_table_1 = Table2 .field_condition_from_table_2 where Table1.condition_from_table_1 = "your_condition"
And that will do the trick. There's other ways you can do it, but this way will bring whatever you need in common from the two tables
Upvotes: 2
Reputation: 4307
This (roughly) will do the trick for you.
select <data> from table1
inner join table2 on table1.column = table2.column
where <mycondition>
Learn more about joins from the MySQL Manual.
Upvotes: 0
Reputation: 2499
Try this:
SELECT * FROM TableA A INNER JOIN Table B ON A.Id = B.Id WHERE condition = 'mycondition'
Upvotes: 3