Forums

CCv5 two tables relations custom query

jhaviro 29 Sep, 2015
Hello. I need a little help with CCv5.
I want to create a list of two related tables (attached picture) ...

Since MyAdmin I managed to do the query correctly:

query OK:

SELECT  `capacidad`.`cd_traductor` AS  `capacidad.cd_traductor` ,  `capacidad`.`cd_servicio` AS  `capacidad.cd_servicio` ,  `capacidad`.`it_jurado` AS  `capacidad.it_jurado` ,  `names`.`id` AS  `names.id` , `names`.`user_id` AS  `names.user_id` ,  `names`.`firstname` AS  `names.firstname` ,  `names`.`cb_idantiguo_traductor` AS  `names.cb_idantiguo_traductor` 
FROM  `j4tyn_z_capacitaciones` AS  `capacidad` 
LEFT JOIN  `j4tyn_comprofiler` AS  `names` ON  `capacidad`.`cd_traductor` =  `names`.`cb_idantiguo_traductor` 
LIMIT 0 , 30


How I can make the same query from ccv5?... I have tried many ways to link (haveone, have many and belongto) left, right, inner ... but I have not got the tittle I need.

Debug copy and paste the result to the list closest I could get ... The configuration of the two tables in "haveone" foreign key "cd_idantiguo_traductor" other automatic settings.


Array
(
    [0] => SELECT `Extension`.`id` AS `Extension.id`, `Extension`.`name` AS `Extension.name` FROM `j4tyn_chronoengine_extensions` AS `Extension` WHERE `Extension`.`enabled` = '1' ORDER BY `Extension`.`ordering` ASC
    [1] => SELECT `Connection`.`id` AS `Connection.id`, `Connection`.`title` AS `Connection.title`, `Connection`.`params` AS `Connection.params`, `Connection`.`extras` AS `Connection.extras`, `Connection`.`published` AS `Connection.published` FROM `j4tyn_chronoengine_connections` AS `Connection` WHERE `Connection`.`title` = 'capacitaciones_2' AND `Connection`.`published` = '1'
    [2] => SELECT COUNT(`capacidad`.`id_cap`) AS `capacidad.count` FROM `j4tyn_z_capacitaciones` AS `capacidad` LEFT JOIN `j4tyn_comprofiler` AS `names` ON `capacidad`.`id_cap` = `names`.`cb_idantiguo_traductor` GROUP BY `capacidad`.`id_cap`
    [3] => SELECT `capacidad`.`id_cap` AS `capacidad.id_cap`, `capacidad`.`cd_traductor` AS `capacidad.cd_traductor`, `capacidad`.`cd_servicio` AS `capacidad.cd_servicio`, `capacidad`.`fc_homologado` AS `capacidad.fc_homologado`, `capacidad`.`fc_deshomologado` AS `capacidad.fc_deshomologado`, `capacidad`.`it_homologado` AS `capacidad.it_homologado`, `capacidad`.`nm_descuento_tarifa` AS `capacidad.nm_descuento_tarifa`, `capacidad`.`nm_minimo` AS `capacidad.nm_minimo`, `capacidad`.`it_jurado` AS `capacidad.it_jurado`, `capacidad`.`nm_jurado` AS `capacidad.nm_jurado`, `capacidad`.`ds_firma_homo` AS `capacidad.ds_firma_homo`, `capacidad`.`ds_firma_deshomo` AS `capacidad.ds_firma_deshomo`, `capacidad`.`ds_motivo` AS `capacidad.ds_motivo`, `names`.`id` AS `names.id`, `names`.`user_id` AS `names.user_id`, `names`.`firstname` AS `names.firstname`, `names`.`cb_idantiguo_traductor` AS `names.cb_idantiguo_traductor` FROM `j4tyn_z_capacitaciones` AS `capacidad` LEFT JOIN `j4tyn_comprofiler` AS `names` ON `capacidad`.`id_cap` = `names`.`cb_idantiguo_traductor` GROUP BY `capacidad`.`id_cap` LIMIT 20
)


Of course, in direct consultation I used fewer fields to speed the query.

TYVM!!!
javierp.
jhaviro 02 Oct, 2015
Hello.

I imagine that you busy. For my part, I think the only solution I've found is to perform the query directly in a form and format the CF v5 list styles CC v5 to be like the rest of listings website.

Anyway, if you have a little time to help, I would be very grateful.

Cordially
javierp.
jhaviro 12 Oct, 2015
Hello.

I still see no help, so share with you how I solved the problem with custom and specific CCv5 querys.

Only you ought to create a view from your MyAdmin or any software to communicate with your data container (eg workbench).
It's simple: you construct a query and the result will save them in a new view. This creates a new table that you can see without having to do anything else.

That is all.

Reviews:
It would be easier CCV5 include the ability to create custom queries ?? I love that this possibility following versions were built.
This topic is locked and no more replies can be posted.