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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.