Jump to content

Recommended Posts

Hello All,

 

I am having trouble with a mysql query.

 

I have 5 tables

jobsmain: Fields - jobid,custid,empid,siteaddress,sitecity,sitestate

empmain: fields - employeeid,empname

jobswo: Fields - WOID,JobID,Installdate,TradeID,WOTypeID,CrewID,WOStatusID

custmain: fields - custid,custfirst,custlast

 

here is the query:

SELECT DISTINCT jobsmain.JobID, jobsmain.SiteAddress, jobsmain.SiteCity, jobsmain.SiteState, jobsmain.SiteZip, jobswo.WOID
FROM jobsmain
INNER JOIN jobswo ON jobsmain.JobID = Jobswo.JobID
INNER JOIN empmain ON jobsmain.Salesperson = empmain.EmployeeID
INNER JOIN custmain ON jobsmain.CustomerID = custmain.CustomerID

 

i have the query working but not the way i would like it too. here is my example of my results.

JOBID Address City State ZIP WOID

2168 121 Willow Dr. SW St. Michael MN 55376 1

2168 121 Willow Dr. SW St. Michael MN 55376 2

 

what i am trying to do is get it to show just the 1 jobid and then when they click show/hide they will see the work orders below the job. example

 

JOBID Address City State ZIP

2168 121 Willow Dr. SW St. Michael MN 55376 [link]SHow/Hide[/link]

WOID InStalldate TradeID WOTypeID CrewID WOStatusID

1 1/29/2009 3 2 36 5

2 2/5/2009 2 3 45 3

 

maybe i am making this harder then it should be. Its got me stumped.

I hope there is enough information here for someone to help me.

 

Thanks

nam797

Link to comment
https://forums.phpfreaks.com/topic/142975-mysql-query/
Share on other sites

Thanks for the reply's.

 

here is my query

 

SELECT jobsmain.JobID, jobsmain.Supervisor, custmain.CustFirst, custmain.CustLast, jobsmain.SiteAddress, jobsmain.SiteCity, jobsmain.SiteState, jobsmain.SiteZip, empmain.EmpName
FROM jobsmain
LEFT JOIN jobswo ON jobsmain.JobID = Jobswo.JobID
LEFT JOIN empmain ON jobsmain.Salesperson = empmain.EmployeeID
LEFT JOIN custmain ON jobsmain.CustomerID = custmain.CustomerID
WHERE jobswo.WOStatusID = '1'
AND jobsmain.ProjectStatus = '4'

 

Here is my results:

 

10872 8 Alex & Jackie Hansen 8733 Troy Marquette Dr. Monticello MN 55362 Jared Braun

11666 93 Reyes & Ermalinda Aguilar 1811 Grand Park Dr Missouri City TX 77489 NULL

11985 93 Alberto Romero 17006 Chapel Parkway Houston TX 77059 NULL

11985 93 Alberto Romero 17006 Chapel Parkway Houston TX 77059 NULL

11924 45 Mark Ourada 1110 Innsbrook ln Buffalo MN 55313 Roger Tiernan

11643 93 John Olivarez 15806 Boridge Cr Houston TX 77053 Brian Johnsted

11643 93 John Olivarez 15806 Boridge Cr Houston TX 77053 Brian Johnsted

11592 93 Steve Strother 5047 E. Ridge Creek Dr Houston TX 77053 NULL

 

I'm trying to get it so i don't get duplicates.

Link to comment
https://forums.phpfreaks.com/topic/142975-mysql-query/#findComment-752814
Share on other sites

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.