Jump to content

Trying to run a MySQL query from php script


arvin

Recommended Posts

Hello,

 

I woyuld like to replace QUERY 1 with Query 2 and would like to include

 

WHERE UPDATED BETWEEN '".$mind[2]."-".$mind[0]."-".$mind[1]." 00:00:00' AND '".$maxd[2]."-".$maxd[0]."-".$maxd[1]." 23:59:59'; ");

 

in QUERY 2 but I having some difficulties.  One of the questions that comes to mind is why are the syntax's different in both queries?  I new to php and have a hard time understanding the syntax's ......

 

 

Here is my current query that works

 

QUERY 1

 

$result = mysql_query("SELECT tickets.UPDATED, tickets.ID , tickets.GRP , tickets.C29 , tickets.OPER , departments.DEPARTMENT FROM tickets INNER JOIN departments ON tickets.GRP = departments.GRP WHERE UPDATED BETWEEN '".$mind[2]."-".$mind[0]."-".$mind[1]." 00:00:00' AND '".$maxd[2]."-".$maxd[0]."-".$maxd[1]." 23:59:59'; ");

 

Here is the phpMyAdmin generated php code

 

QUERY 2

 

$sql = 'SELECT messages.DATE, tickets.ID, departments.DEPARTMENT, tickets.C29, messages.AUTHOR'
        . ' FROM departments RIGHT JOIN (messages INNER JOIN tickets ON messages.TID = tickets.ID) ON departments.GRP = tickets.GRP'
        . ' WHERE (((tickets.C29) Not In ("CABS","Billing Inquiries","Phone Inquiries","Monthly Billing","Meeting","PP&R","Data","NCAMS","Alarms","Bus Resale","Broadcast","PIC","CPR","Trouble Shooter","Vendor PRI","Wholesale","Trainer","Trainee","Directory")) AND ((messages.AUTHOR) In (\'Annette\',\'Barb\',\'Belinda\',\'Bernadine\',\'Carole\',\'Debbie\',\'Dolly\',\'Donna\',\'Etta\',\'Jackie\',\'Kelly\',\'Lea\',\'Terry\',\'Vickie\',\'Jody\')))'; 

 

any help is appreciated

 

Thank you in advance

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.