Hi, i'm trying to execute the following query: -
SELECT CONCAT_WS(' ', g.genus_name, s.species_name, i.rank, i.infraspecies_name, conf.auth1, conf.auth2 ) AS scientific_name,
-
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
-
FROM plants AS p
-
LEFT JOIN (genera AS g, species AS s)
-
ON (p.genus_num = g.genus_id AND p.species_num = s.species_id)
-
LEFT JOIN (confirmations AS conf)
-
ON (p.plant_id = conf.plant_num)
-
LEFT JOIN (plant_growth_habits AS pgh, growth_habits AS gh)
-
ON (p.plant_id = pgh.plant_num)
-
LEFT JOIN (plant_distributions AS pd, gen_distribs AS gd)
-
ON (p.plant_id = pd.plant_num)
-
LEFT JOIN (plant_common_names AS pcn, common_names AS cn)
-
ON (p.plant_id = pcn.plant_num)
-
LEFT JOIN (unvouchered_images AS ui)
-
ON (p.plant_id = ui.plant_num)
-
LEFT JOIN (infraspecies AS i)
-
ON (p.infraspecies_num = i.infraspecies_id)
-
WHERE scientific_name LIKE '%sesuvium%'
-
GROUP BY scientific_name ORDER BY scientific_name
-
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?
2 1419
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.
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: -
SELECT
-
CONCAT_WS(' ',g.genus_name,s.species_name,i.rank,i.infraspecies_name,
-
conf.auth1,conf.auth2) AS scientific_name, cn.common_name,
-
GROUP_CONCAT(DISTINCT cn.common_name ORDER BY cn.common_name SEPARATOR ', ' ) AS common_names,
-
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,
-
gd.gen_distrib_name, GROUP_CONCAT(DISTINCT gd.gen_distrib_name ORDER BY gd.gen_distrib_name SEPARATOR ', ') AS general_dists
-
FROM plants AS p
-
LEFT JOIN genera AS g
-
ON g.genus_id = p.genus_num
-
LEFT JOIN species AS s
-
ON s.species_id = p.species_num
-
LEFT JOIN confirmations AS conf
-
ON conf.plant_num = p.plant_id
-
LEFT JOIN (plant_growth_habits AS pgh INNER JOIN growth_habits AS gh ON gh.growth_habit_id = pgh.growth_habit_num)
-
ON pgh.plant_num = p.plant_id
-
LEFT JOIN (plant_distributions AS pd INNER JOIN gen_distribs AS gd ON gd.gen_distrib_id = pd.gen_distrib_num)
-
ON pd.plant_num = p.plant_id
-
LEFT JOIN (plant_common_names AS pcn INNER JOIN common_names AS cn ON cn.common_name_id = pcn.common_name_num)
-
ON pcn.plant_num = p.plant_id
-
LEFT JOIN unvouchered_images AS ui
-
ON p.plant_id = ui.plant_num
-
LEFT JOIN infraspecies AS i
-
ON p.infraspecies_num = i.infraspecies_id
-
WHERE scientific_name LIKE '%sesuvium%' GROUP BY scientific_name ORDER BY scientific_name
-
The above sql works (processes in ~ 0.2 seconds now), but i have another little problem with the output from -
CONCAT_WS(' ',g.genus_name,s.species_name,i.rank,i.infraspecies_name,conf.auth1,conf.auth2) AS scientific_name
-
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...
Sign in to post your reply or Sign up for a free account.
Similar topics
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,...
|
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...
|
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...
|
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` , ...
|
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...
|
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
|
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 =...
|
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...
|
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() :...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
| |