Query MySql for User with Single Record
Posted: Thu Jul 10, 2008 10:14 pm
Hi,
I'm trying to create a query of table of purchase records to return only users who have made a single purchase, so basically it would return one-time purchasers. Every purchaser is assigned a unique id number (userid), so i've been trying to come up with a quick and simple query that searches for unique userids in the sales_record table. I can put together a script to do it the hard way (ie: do an initial query of the userid table, then query the sales_record table for each userid and only print out the rows returned where mysql_num_rows == 1) but i was wondering if anyone knew of a more elegant/quick way to do it.
Thanks!
I'm trying to create a query of table of purchase records to return only users who have made a single purchase, so basically it would return one-time purchasers. Every purchaser is assigned a unique id number (userid), so i've been trying to come up with a quick and simple query that searches for unique userids in the sales_record table. I can put together a script to do it the hard way (ie: do an initial query of the userid table, then query the sales_record table for each userid and only print out the rows returned where mysql_num_rows == 1) but i was wondering if anyone knew of a more elegant/quick way to do it.
Thanks!