table 1
ID FIELD 1 yada yada
table 2
ID FIELD 2 yada yada
SELECT banner_images.ID, file, description, class, banner_images.grouping FROM banner_images LEFT JOIN banner_stats ON banner_images.ID = banner_stats.ID GROUP BY banner_images.ID HAVING class = 'A' AND banner_images.grouping != 'B' ORDER BY RAND() LIMIT 1
I had the above query but i still get results whose values ID that appears in both tables
I thought that a LEFT-JOIN gave results that DONT match???!! when it comes to understanding the types of joins i really am stumnped as to how they work and event a simple
WHERE table1_id != table2_id
gives me results that exists in both tables.
Kendall
i have 2 tables i created for a banner ad system...banner_info banner_stats
when a banner is displayed it writes the stats to the banner_stat table
What i wanted to do is make sure that all the banners in banner_info are displayed at least once.
so im trying to create a query that will return results from banner_info whose id is not in banner_stats LIMIT 1
the problem is im still getting results whose id's are in both tables
SELECT banner_images.ID, file, description, class, banner_images.grouping FROM banner_images LEFT JOIN banner_stats ON banner_images.ID = banner_stats.ID WHERE banner_images.ID NOT IN (banner_stats.ID) AND banner_images.class = '".$type."' AND banner_images.grouping != '".$group."' ORDER BY RAND() LIMIT
Funny thing doe...when it has reached the last banner to be displayed...i get a 0 as an id number....(this is when testing the php script) yet when i do a query from the msyql commmand...i will get the last banner...but testing it using the script hmmmm...i dont get it i get and id = 0 when there is an id...hmmm