Reputation: 1391
Which approach is better:
PHP
, or;MySQL
and
request them instead?For example, I have these tables:
And I want to select these information:
country, region, city and company details by defined language e.g. en
.
And this is my query:
SELECT
ctry_lng.translated_name,
rgn_lng.translated_name,
cty_lng.translated_name,
cmp.phone,
cmp.email,
cmp.url,
cmp_lng.name,
cmp_lng.info
FROM
language AS lng,
country AS ctry,
region AS rgn,
city AS cty,
company AS, cmp,
cmp_lng,
ctry_lng,
rgn_lng,
cty_lng
WHERE lng.code = "en"
AND ctry_lng.lng_id = lng.id
AND ctry_lng.ctry_id = ctry.id
AND rgn.ctry_id = ctry.id
AND rgn_lng.rgn_id = rgn.id
AND rgn_lng.lng_id = lng.id
AND cty.rgn_id = rgn.id
AND cty_lng.cty_id = cty.id
AND cty_lng.lng_id = lng.id
AND cmp.cty_id = cty.id
AND cmp_lng.cmp_id = cmp.id
AND cmp_lng.lng_id = lng.id
ORDER BY cmp_lng.name ASC;
The query above is that which I am going to send from
PHP
toMySQL
. Or should I create a view, a function or a stored procedure and then send query fromPHP
toMySQL
its name.
Thanks anyway!
Upvotes: 1
Views: 418
Reputation: 2094
The query doesn't seem very complex in its nature. Stored procedures and views are not relevant to optimizing this query and you can read more about them in this answer
Upvotes: 1