What is the best way to accomplish this using the minimum number of sql queries.
I have two tables, one contains a banner id, link url, img url, etc.
The other table contains the banner id, user id, timestamp. The user id is the user who clicked the banner.
Now I want to select and format the banners from the first table. But I only want the rows returned to be rows that are not contained in the second table.
For example, user id 2 has clicked banner id 1. So when the query is executed banner id 1 should not be selected from the first table because it has already been clicked on.
My previous approached I just select all rows from the first table then performed a second sql query with the banner id returned from the first query. But this is too slow and uses too many sql connections.
Any help appreciated.