Question

Ok, so I can't seem to get this to work, but here is what I wan't to do. I have 2 tables one

like this

Table1
----------
Row1


And this

Table2
----------
Row2


I want to get the data from Table1 where Row2 equals "thisvalue", in php. Any idea how I should go about doing this? Thanks.

Was it helpful?

Solution

You join the tables together

SELECT table1.* FROM table1 t1 JOIN table2 t2 ON t1.row1 = t2.row2

If you want only a row with a specific rw2-value, you can specify that in the WHERE clause

SELECT table1.* FROM table1 t1 JOIN table2 t2 ON t1.row1 = t2.row2 where t2.row='your value'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top