Page 1 of 1

Querying two tables in the same sentence

Posted: Mon Feb 09, 2009 6:18 am
by JKM
Hi there!

I want to query two tables. It should just select rows from table xxx and where column='.$_POST['nick'].' from another table. Like this:
- SELECT * FROM presentation where username='.$fetch['nick'].' AND (SELECT * FROM users WHERE activated='1').
- Let's say that this page shouldn't show presentations where the status of $fetch/_POST['nick'] isn't activated (0).
- Both tables got the column 'username'.

Code: Select all

<?php
mysql_connect('xxx','xxx','xxx') or die("mysql error");
mysql_select_db("xxx") or die("mysql error");
$query = mysql_query("SELECT * FROM xxx") or die(mysql_error());
while($fetch = mysql_fetch_array($query)) {?>
    <p>blalba <?php $fetch['blabla']; ?>
<?php
} 
?>
Thanks for any help. Sorry if it's explained bad.

Re: Querying two tables in the same sentence

Posted: Mon Feb 09, 2009 6:24 am
by VladSun