php - Doubts about creating an specific query -
ok have database generate ticket code everytime users buy item. code have oportunity win price
to win price have go register form, code ask.. thats data generated. ask name, mail address, , other non important stuff
this part working nice , properly. need create o new function detect best buyers. when enter code participate , ask mail, have noticed, enters same mail each time register code. best way think select best clients, , interested on promotions also.
so think best build query search mail row .. inside users table, , coincidences, , query can drop me list of "repited" mails in dsc order,
is posible, can build query this? how?
ok , thansk comments (why downvote??) anyway
the structure is
id | name | lastname | mail | phone | zipcode | birth |
and sorry @ moment cant figure out query thats why ask. sorry been fool ,
how order number of times element occurs in table
select count(*) top,mail,name lastname users group mail order top desc
this works because of aggregate functions
count
picks number of rows in individual elements of group (so suppose ran count without group return number of rows in table)
group by
groups rows common elements column(s) specified group by.
so in above case group mails , count rows in each group.
Comments
Post a Comment