Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

mysql php - No records found


Hello Experts,

I really need a light on this problem.

a php page with a select statement caching data from a database was working fine but today the page is showing "no records found".

I run to check that the database on the hosting server... its fine!
and also to run the same select statement in the phpmyadmin.

The only error while running the same select statement in phpmyadmin was the "1104 would examine more than MAX_JOIN_SIZE rows..."

I added in the phpmysql above the select statement the following: SET SQL_BIG_SELECTS=1;

and all is fine! i got all the results!

i copied and paste the same select statement into the php page and upload it and then again... it prints "no results found".

should i add "SET SQL_BIG_SELECTS=1;" in the PHP page as well?

here is the main code please if someone can see where is the problem?
$search_query="";
$list_companies = $mysqli_link->prepare(
"SELECT `vo-companies`.company_id,
`vo-companies`.company_name AS company,
OFFICEQ.startdate,
OFFICEQ.officeplan,
OFFICEQ.officecenter,
PARTNERQ.partnername,
PARTNERQ.partnerLName,
EMAILQ.email,
PHONESQ.phone,
ADDRESSQ.address_id,
ADDRESSQ.address1, 
ADDRESSQ.address2,
ADDRESSQ.city,
ADDRESSQ.state,
ADDRESSQ.zip,
ADDRESSQ.country
FROM `vo-companies`
LEFT JOIN (SELECT 
`vo-offices`.office_id,
`vo-offices`.company_id,
`vo-offices`.office_date as startdate,
`vo-offices`.office_plan,
`vo-offices`.office_center,
`vo-plans`.plan_name as officeplan,
`vo-centers`.center_name as officecenter
FROM `vo-offices` LEFT JOIN `vo-plans` ON `vo-offices`.office_plan=`vo-plans`.plan_id LEFT JOIN `vo-centers` ON `vo-offices`.office_center=`vo-centers`.center_id GROUP BY `vo-offices`.company_id)
AS OFFICEQ on OFFICEQ.company_id=`vo-companies`.company_id
LEFT JOIN (SELECT 
`vo-partners`.partner_id,
`vo-partners`.company_id,
`vo-partners`.partner_fname as partnername,
`vo-partners`.partner_lname as partnerLName
FROM `vo-partners` GROUP BY `vo-partners`.company_id)
AS PARTNERQ on PARTNERQ.company_id=`vo-companies`.company_id
LEFT JOIN (SELECT 
`vo-company_emails`.company_id,
`vo-company_emails`.company_emails_email as email 
FROM `vo-company_emails` GROUP BY `vo-company_emails`.company_id)
AS EMAILQ on EMAILQ.company_id=`vo-companies`.company_id
LEFT JOIN (SELECT 
`vo-company_phones`.company_id,
`vo-company_phones`.company_phones_phone as phone 
FROM `vo-company_phones` GROUP BY `vo-company_phones`.company_id)
AS PHONESQ on PHONESQ.company_id=`vo-companies`.company_id
LEFT JOIN (SELECT 
`vo-company_addr`.company_addr_id as address_id, 
`vo-company_addr`.company_id,
`vo-company_addr`.company_addr_line1 as address1,
`vo-company_addr`.company_addr_line2 as address2, 
`vo-company_addr`.company_addr_city as city,
`vo-company_addr`.company_addr_state as state, 
`vo-company_addr`.company_addr_zip as zip,
`vo-countries`.name AS country
FROM `vo-company_addr` LEFT JOIN `vo-countries` ON `vo-company_addr`.company_addr_country_iso=`vo-countries`.iso GROUP BY `vo-company_addr`.company_id) 
AS ADDRESSQ on ADDRESSQ.company_id=`vo-companies`.company_id WHERE `vo-companies`.company_active='Y' $search_query");

$list_companies->execute();
$list_companies->bind_result($company_id, $company_name, $start_date, $plan, $center, $partner_fname, $partner_lname, $company_email, $company_phone, $company_addr_id, $address_line1, $address_line2, $city, $state, $zip, $country);
$list_companies->store_result();
if($list_companies->num_rows==0) echo "<tr><td colspan='8' align='center'> No results found.</td></tr>";
while ($list_companies->fetch()) {
echo "<tr>
<td nowrap='nowrap'><a href='company_details.php?cid=$company_id'>$company_name</a></td>";
}
$list_companies->close();

Open in new window

Avatar of Amar Bardoliwala
Amar Bardoliwala
Flag of India image

Hello Refael,

I think following link can give you some good information on your problem.

Please look at it and act accordingly.

http://stackoverflow.com/questions/950465/mysql-sql-big-selects

According to me you can add "SET SQL_BIG_SELECTS=1;" in php code too if necessary.

Hope this will help you.

Thanks
Avatar of Beverley Portlock
I would edit /etc/my.cnf and set SQL_BIG_SELECTS to ON then you know the problem is resolved no matter how the query is run.
Avatar of Refael

ASKER


Hello amar_bardoliwala, bportlock,

the article was not really helping as i do not know where and how to add it.
i tried to search on the hosting server for the etc/my.cnf  or mysql.cnf but could not find any.
i have a (require) config file in the php page, should i add it there, can you show me how?

anyway i add a limit "LIMIT 20" to the end like so:

WHERE `vo-companies`.company_active='Y' LIMIT 20 $search_query

still showing up no records! please HELP!
ASKER CERTIFIED SOLUTION
Avatar of Amar Bardoliwala
Amar Bardoliwala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eZov
eZov

Try to add at the end of your SQL query LIMIT 0, 100; to limit the number of rows returned. This will tell you if the number of rows is too big to be processed by one sql query.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial