CodeIgniter Forums
Want a Codeigniter Query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Want a Codeigniter Query (/showthread.php?tid=67662)



Want a Codeigniter Query - apysan - 03-22-2017

[attachment=825][attachment=826]
I have an issue in connecting the data in my current project, Please look in the details in file attached.


RE: Want a Codeigniter Query - neuron - 03-22-2017

PHP Code:
insert into t_category (categoryparent_category)
(
select t1.t_categoryt3.parent_id 
from t_csv t1
left join t_category t2 on t1
.category t2.category
left join t_pcategory t3 on t1
.parent_category t3.parent_category
where t2
.id is null and t3.parent_category is not null) as t5 
try this query, is shoul work.  

And read about  "correlated and non correlated query" , http://www.programmerinterview.com/index.php/database-sql/correlated-vs-uncorrelated-subquery/

your query is uncorrelated, thus its much slower than correlated ones, query above is correlated. when u have 100k > rows, using uncorrelated query may take hours to finish, where correlated ones may take 1-5mins


RE: Want a Codeigniter Query - apysan - 03-23-2017

I got this error:
-----------------
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as t5' at line 6

insert into t_category (category, parent_category)
(select CSV.t_category, PCAT.parent_id from t_csv CSV
left join t_category CAT on CSV.category = CAT.category
left join t_pcategory PCAT on CSV.parent_category = PCAT.parent_category
where CAT.id is null and PCAT.parent_category is not null) as t5

Filename: models/Super_admin_model.php

Line Number: 1030


RE: Want a Codeigniter Query - php_rocs - 03-28-2017

@apysan,

Have you resolved this issue?