I have a table like this:
click_id | event | page |
---|---|---|
01 | ad_click | landing_page01 |
01 | page_view | landing_page01 |
01 | page_view | landing_page01 |
01 | offer_click | landing_page01 |
02 | ad_click | landing_page01 |
02 | page_view | landing_page01 |
02 | offer_click | landing_page01 |
02 | offer_click | landing_page01 |
I would like to get only rows that have unique events for each click_id. So I don’t want to see if somebody views the page 10 times, I only want to know if he viewed the page at all. The same goes for the offer_click event. I only want to see who clicked on the offer at all, because some people click on the offer link 10 times and gives me bad click-through-rate data when I display it.
All ad_click events have a unique click_id, because that’s where they get their id, so that’s fine.
I also want to select the whole rows, because there are a lot more colums with timestamp, IP, etc.
Please help me, I’m mighty confused by all the MySQL syntax.
Also if the way I organize my data is bad, please let me know. I haven’t really studied databases and stuff and just winged it. I have several hundred thousand rows now in my “tracker”, all in one table. It works for me, but I struggle with this particular problem.
The solution I had before was multiple queries, but it took several minutes to load, now I’m using a php array to check for duplicate click_id’s for each event, but that adds another 5 seconds just to check for one event. I’m sure it’s possible to do it faster with MySQL.
Thanks!