please help me with joins

hello
i have made code that is working and using join function

[php]
SELECT * FROM link_ads
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
[/php]
it displays link_ads elements which aren’t in user_ads_history.uid that is working
my question is
how can i unite more tables like that? and also i need select only that rows where ad_amount >=1
i have tried all these options
[php]
SELECT * FROM link_ads WHERE ad_amount>=1
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
[/php]
[php]
SELECT * FROM link_ads WHERE link_ads.ad_amount>=1
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
[/php]
[php]
SELECT ad_amount FROM link_ads WHERE link_ads.ad_amount>=1
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
[/php]
ERROR: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in

and also after that i need to same thing but with other tables
my code:
[php]
SELECT * FROM link_ads WHERE link_ads.ad_amount>=1
UNION ALL
SELECT * FROM code_ads WHERE code_ads.ad_amount>=1
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
INNER JOIN user_ads_history
ON code_ads.uid = user_ads_history.uid
[/php]

i have solved problem with ad_amount and it is working
[php]
SELECT * FROM link_ads
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
WHERE link_ads.ad_amount >=1
[/php]

but i can’t add 3 more tables i was googling but still no one of that did work

i actually made that one too but i got other problem

my code is

[php]
SELECT * FROM link_ads
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
AND link_ads.ad_owner_id=user_ads_history.ad_owner_id
WHERE link_ads.ad_amount >=1
UNION ALL
SELECT * FROM youtube_ads
INNER JOIN user_ads_history
ON youtube_ads.uid = user_ads_history.uid
AND link_ads.ad_owner_id=user_ads_history.ad_owner_id
WHERE youtube_ads.ad_amount >=1
UNION ALL
SELECT * FROM code_ads
INNER JOIN user_ads_history
ON code_ads.uid = user_ads_history.uid
AND link_ads.ad_owner_id=user_ads_history.ad_owner_id
WHERE code_ads.ad_amount >=1
UNION ALL
SELECT * FROM adfly_ads
INNER JOIN user_ads_history
ON adfly_ads.uid = user_ads_history.uid
AND link_ads.ad_owner_id=user_ads_history.ad_owner_id
WHERE adfly_ads.ad_amount >=1
[/php]

i need to select uid and ad_owner_id of each row and table and check how many is there in user_ads_history table

this code is giving me error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in

never mind i fixed everything
[php]
SELECT * FROM link_ads
INNER JOIN user_ads_history
ON link_ads.uid = user_ads_history.uid
AND user_ads_history.viewer_id=$id
WHERE link_ads.ad_amount >=1
UNION ALL
SELECT * FROM youtube_ads
INNER JOIN user_ads_history
ON youtube_ads.uid = user_ads_history.uid
AND user_ads_history.viewer_id=$id
WHERE youtube_ads.ad_amount >=1
UNION ALL
SELECT * FROM code_ads
INNER JOIN user_ads_history
ON code_ads.uid = user_ads_history.uid
AND user_ads_history.viewer_id=$id
WHERE code_ads.ad_amount >=1
UNION ALL
SELECT * FROM adfly_ads
INNER JOIN user_ads_history
ON adfly_ads.uid = user_ads_history.uid
AND user_ads_history.viewer_id=$id
WHERE adfly_ads.ad_amount >=1
[/php]

thank you for letting me spam your forum and not banning me yet, probably i look like crazy person who talks to himself but for some reason this is only way i can fix my code

Sponsor our Newsletter | Privacy Policy | Terms of Service