Sql Statement to gather latest users emails from past 6 months - Joomla

Discussion in 'MySQL' started by Beefandy, Jan 4, 2012.

  1. #1
    Hi, I want to run a statement which will list all the latest users. I say 6 months but a few months would do. Basically just the latest people who have logged into my Joomla site. I want to do this so I could then export the emails and send these people a message.

    Saying that, I would probably need to know how to export the emails too.

    Thanks
     
    Beefandy, Jan 4, 2012 IP
  2. mattchis

    mattchis Active Member

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #2
    If using phpMyAdmin:
    1. Select Joomla Database
    2. Click Query Tab
    3. Run this Query: SELECT email FROM `jos_users` WHERE `lastvisitDate` >= '2011-07-01' ORDER BY `jos_users`.`lastvisitDate` ASC
    4. Click Export and choose your preferred format

    If you have Shell Accesss:
    1. Run this command: mysql -uexampleuser -p examplejoomladatabase -B -e "SELECT email FROM \`jos_users\` WHERE \`lastvisitDate\` >= '2011-07-01' ORDER BY \`jos_users\`.\`lastvisitDate\` ASC;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv
     
    mattchis, Jan 4, 2012 IP