SQL Query to Show the Count for Queued ‘promotionmagnet’ Solos

This is a SQL query to determine how many Promotion Magnet Solos are in queue to send.  This can be adapted to anything, just look at your data to determine how to build the query.
  • You must have CPANEL access to your hosting server.  
  • You must have access to your MySQL database using phpMyAdmin.  
  • ]Select the database
  • Select the table “solos”
  • Copy/paste the SQL below into the SQL Query window and lick GO
SELECT distinct count(approved) FROM `solos` where (approved=’1′ and sent = ‘0’) and url like ‘%promotionmagnet%’;
group by approved

Explanation

  • SELECT FROM SOLOS – tells the SQL engine to use the SOLOS table in the current database
  • distinct count(approved)  – this limits your answer to one record, which contains the count of the number of records
  • where (approved=’1′ and sent = ‘0’) – this sets up the query to include only those records that have been approved AND not sent
  • and url like ‘%promotionmagnet%’ – also be sure the URL field of the record CONTAINS the partial string promotionmagnet
  • group by approved – this tells the SQL engine that some operation being executed that uses calculations on the approved field
  • ; – all SQL queries end in a semicolon

PHP

If you are using a PHP program to do this query, create the SELECT query as a variable such as $sql then execute.

$sql = “SELECT distinct count(approved) FROM `solos` where (approved=\’1\’ and sent = \’0\’) and url like \’%promotionmagnet%\’\n”
    . “group by approved\n”
    . “”;