Jump to content

mySQL queary on PHP geting to much data.


nezbo

Recommended Posts

Hi

 

I have this code ::

 

		// ----------------------------- select infor from mySQL ------------------------------//
	$getInfo = mysql_query("SELECT
		person.*, 
		site.*, 
		_fullrota.*,
		_daysoftheweek.*,
		_duty.*, 
		_payrate.*,
		_weeknumber.*,
		holidayrequest.*
	FROM 
		 person, site, _fullrota, _daysoftheweek, _duty, _payrate, _weeknumber, holidayrequest 
	WHERE 
		(
		site.SiteID = _fullrota.fullLocation AND _weeknumber.weekID = _fullrota.fullWeekNumber 
		AND _payrate.payRateID = _fullrota.fullPayRate AND _duty.dutyID = _fullrota.fullDuty 
		AND person.CallID = _fullrota.fullStaffName AND _daysoftheweek.dayID = _fullrota.fullRotaDay 
		$selectedUser AND _fullrota.Other = 0 AND _fullrota.giveAway = 0 AND _fullrota.sickRequest = 0 AND trainingDays = 0 
		AND _fullrota.fullRotaID = holidayrequest.shiftID  
		)
		||
		(
		site.SiteID = _fullrota.fullLocation AND _weeknumber.weekID = _fullrota.fullWeekNumber 
		AND _payrate.payRateID = _fullrota.fullPayRate AND _duty.dutyID = _fullrota.fullDuty 
		AND person.CallID = _fullrota.fullStaffName AND _daysoftheweek.dayID = _fullrota.fullRotaDay 
		$selectedUser AND _fullrota.Other = 0 AND _fullrota.giveAway = 0 AND _fullrota.sickRequest = 0 AND trainingDays = 0 
		AND _fullrota.holidayRequest = 1 
		)
	ORDER BY 
		_fullrota.fourWeekDate ASC, _weeknumber.weekID ASC, _daysoftheweek.Priorty ASC, _fullrota.fullStartTime ASC") or die(mysql_error());
	// -----------------------------/select infor from mySQL ------------------------------//

 

The problem is that i am geting the info back that i needed muitlplied by the number of enterys in the holidayrequest table. i am not to sure if this make sence

 

i will try and explain it a bit better by an example

 

number of holiday requests = 3

 

 

Staff name  |  Date

---------------------

Steve          |  **********

Steve          |  **********

Steve          |  **********

Bert            |  *********

Bert            |  *********

Bert            |  *********

 

etc...

 

please Help....

Neil

Link to comment
https://forums.phpfreaks.com/topic/73476-mysql-queary-on-php-geting-to-much-data/
Share on other sites

Doing joins can often result in data sets that have rows that appear to be duplicates.. Can you pare this down into a much simpler query and result set (say using three tables and three fields on each) to make it easier to figure out? I'm guessing nobody has replied because they see that monster query and don't want to be bothered with hacking their way through it.

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.