473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Query is crashing phpmyadmin/mysql

Hi, i'm trying to execute the following query:

Expand|Select|Wrap|Line Numbers
  1. SELECT CONCAT_WS(' ', g.genus_name, s.species_name, i.rank, i.infraspecies_name, conf.auth1, conf.auth2 ) AS scientific_name, 
  2. cn.common_name, GROUP_CONCAT(cn.common_name ORDER BY cn.common_name SEPARATOR ', ' ) AS common_names, ui.unvouch_image_src, ui.unvouch_image_alt, gh.growth_habit, gd.gen_distrib_name 
  3. FROM plants AS p 
  4. LEFT JOIN (genera AS g, species AS s) 
  5. ON (p.genus_num = g.genus_id AND p.species_num = s.species_id)
  6. LEFT JOIN (confirmations AS conf) 
  7. ON (p.plant_id = conf.plant_num)
  8. LEFT JOIN (plant_growth_habits AS pgh, growth_habits AS gh)
  9. ON (p.plant_id = pgh.plant_num)
  10. LEFT JOIN (plant_distributions AS pd, gen_distribs AS gd)
  11. ON (p.plant_id = pd.plant_num)
  12. LEFT JOIN (plant_common_names AS pcn, common_names AS cn) 
  13. ON (p.plant_id = pcn.plant_num)
  14. LEFT JOIN (unvouchered_images AS ui) 
  15. ON (p.plant_id = ui.plant_num)
  16. LEFT JOIN (infraspecies AS i) 
  17. ON (p.infraspecies_num = i.infraspecies_id)
  18. WHERE scientific_name LIKE '%sesuvium%'
  19. GROUP BY scientific_name ORDER BY scientific_name
  20.  
It used to be a bit less and after i added the last 3 or so joins is when the crashing began. Is something wrong with the way i am joining?
Nov 13 '07 #1
2 1419
pbmods
5,821 Expert 4TB
Heya, Dipperdan.

How is it crashing? Are you getting a white screen? 500 error? Is the request timing out?

Try EXPLAINing the query to see if you're dealing with a particularly slow query.
Nov 14 '07 #2
Heya, Dipperdan.

How is it crashing? Are you getting a white screen? 500 error? Is the request timing out?

Try EXPLAINing the query to see if you're dealing with a particularly slow query.
It was timing out, like reaaaly long, then i had to restart mysql. But i got it solved tho i reworked the query a bit:

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2. CONCAT_WS(' ',g.genus_name,s.species_name,i.rank,i.infraspecies_name,
  3. conf.auth1,conf.auth2) AS scientific_name, cn.common_name,
  4. GROUP_CONCAT(DISTINCT cn.common_name ORDER BY cn.common_name SEPARATOR ', ' ) AS common_names, 
  5. ui.unvouch_image_src, ui.unvouch_image_alt, gh.growth_habit, GROUP_CONCAT(DISTINCT gh.growth_habit ORDER BY gh.growth_habit SEPARATOR ', ') AS growth_habits,
  6. gd.gen_distrib_name, GROUP_CONCAT(DISTINCT gd.gen_distrib_name ORDER BY gd.gen_distrib_name SEPARATOR ', ') AS general_dists
  7. FROM plants AS p 
  8.  LEFT JOIN genera AS g 
  9.     ON g.genus_id = p.genus_num
  10.  LEFT JOIN species AS s 
  11.     ON s.species_id = p.species_num
  12.  LEFT JOIN confirmations AS conf 
  13.     ON conf.plant_num = p.plant_id
  14.  LEFT JOIN (plant_growth_habits AS pgh INNER JOIN growth_habits AS gh ON gh.growth_habit_id = pgh.growth_habit_num) 
  15.     ON pgh.plant_num = p.plant_id
  16.  LEFT JOIN (plant_distributions AS pd INNER JOIN gen_distribs AS gd ON gd.gen_distrib_id = pd.gen_distrib_num) 
  17.     ON pd.plant_num = p.plant_id
  18.  LEFT JOIN (plant_common_names AS pcn INNER JOIN common_names AS cn ON cn.common_name_id = pcn.common_name_num) 
  19.     ON pcn.plant_num = p.plant_id 
  20.  LEFT JOIN unvouchered_images AS ui
  21.     ON p.plant_id = ui.plant_num
  22.  LEFT JOIN infraspecies AS i 
  23.     ON p.infraspecies_num = i.infraspecies_id
  24. WHERE scientific_name LIKE '%sesuvium%' GROUP BY scientific_name ORDER BY scientific_name
  25.  
The above sql works (processes in ~ 0.2 seconds now), but i have another little problem with the output from
Expand|Select|Wrap|Line Numbers
  1. CONCAT_WS(' ',g.genus_name,s.species_name,i.rank,i.infraspecies_name,conf.auth1,conf.auth2) AS scientific_name
  2.  
where there will not always be a value for conf.auth1 and/or conf.auth2 and the concatenation sometimes prints say for e.g. there was no value for conf.auth2 "Sesuvium microphyllum Willd. NULL". Is this the default behaviour of concat_ws, can i get around this or would i just have to strip that out using php?

Thanks...
Nov 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob | last post by:
I am making the jump from ASP/Access to PHP/MySQL. And I really miss the ease of generating sql queries inherent in access. I've been reduced on occassion to modeling the database in access,...
4
by: JimC | last post by:
I have PHP installed on a Windows XP platform using IIS as server. When updating a MySQL database field set to MEDIUMTEXT in phpMyAdmin, the transaction seems to fail if the text contains more...
10
by: johnnyboy10017 | last post by:
I am having a hell of a time with what I think is a very simple query: It won't actually insert a new record into the specified table, but returns no error, in fact it returns "1" (or true) that...
3
by: JC-Atl | last post by:
I am trying to do this in the SQL page of phpMyAdmin, but I get a syntax error. Can someone please help me out ? Thanks for your time and efforts! JC INSERT INTO `Test` ( `pkey` , `col2` , ...
0
by: Gnarlodious | last post by:
This is some odd behavior, I'm hoping someone can explain. I have a TiBook running 4.0.17 and phpMyAdmin 2.5.5-pl1 where MySQL hostname is configured as "Gnarlodious-TiBook" (machinename). So...
2
by: Daniel Mercier | last post by:
Hi, I'm new to mysql and just installed phpmyadmin. Here is the versions info: System Linux linlyne.spider.sense 2.4.22-1.2199.nptl #1 PHP Version 4.3.8
17
by: erikcw | last post by:
Hi all, I'm trying to run the following query: amember_db = MySQLdb.connect(host="localhost", user="**********", passwd="*****", db="*******") # create a cursor self.amember_cursor =...
2
by: Cindy Chambers | last post by:
I have meeting minutes that need to be paged through via my website. I have created a developer server on my local machine and when I run the PHP code against the MySQL table that I imported from...
8
by: Jonathan Sachs | last post by:
I just tried to install phpMyAdmin on my system, and I can't get it to work. When I tried to run the setup procedure (setup.php) I got the following message: Fatal error: session_start() :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.