how to fetch data from multiple tables MySQL
I am looking some help in php+MySQL+jquery I have 2 tables
table1 table 1 have 4 colume (id, title, desc, thumb_img)
tabel2 table 2 have 3 colume(id, table1id, img)
I just want to compare 2 table with the value of $_get['QS']; and show the records fr开发者_StackOverflow社区om both (title, desc, img)
Looking forward for the help.:)
SELECT t1.title, t1.desc, t2.img
FROM table1 AS t1
JOIN table2 AS t2
ON t1.id=t2.table1id
WHERE somefieldyoudidntspecify=:qs
<?php
$query="select * from table1 t1 inner join table2 t2 on t2.table1id = t1.id where SomeField = '". mysql_real_escape_string($_get['QS'])."'"
?>
精彩评论