I've two that i want to select from the first table depending on the second table.
First Table
ex_instagram_p:
id (int)
username (varchar)
cpc (int)
type (varchar)
active (int)
Second Table
exchanges
id (int)
user (varchar)
exid (int)
What i want :
select values from ex_instagram_p and to make sure it does not equal any entry in the second table exchanges Where exchanges.user = $username rows Doesn't contains ex_instagram_p.id on exchanges.id
let me clear it
for example table one is for blog articles
so the user will show articles != his username and active = 1 and type ='".follow."'
and the second table is the views.
so if there is an entry on the second table with user = $username and exid = firsttable.id
this entry has been already viewed by this user and i don't want him to view it again.
Actually i need if no entry on the exchanges table got the values of
user - exid
$username - i.id
if this doesn't exist is should continue
Here is the code i've created, but it does not work
$prowz= mysql_query("SELECT i.*
FROM ex_instagram_p as i, exchanges as e
HAVING COUNT(e.user = '".$username." And e.exid = i.id) = 0
WHERE
AND i.type = '".follow."'
AND i.active=1
AND i.username != '".$username."'
ORDER BY i.cpc DESC
LIMIT 1;");