Database error #1066 |
guys please help me with this error:
A Database Error Occurred Error Number: 1066 Not unique table/alias: 'ms_sms' SELECT *, `ms_tags`.`id` as `tag_ids` FROM `ms_sms` LEFT JOIN `ms_sms` ON `ms_sms`.`id` = `ms_tags_meta`.`sms_id` LEFT JOIN `ms_tags_meta` ON `ms_tags_meta`.`tag_id` = `ms_tags`.`id` GROUP BY `id` ORDER BY `id` DESC Filename: controllers/me/do.php Line Number: 70 -------------------------------------------- and here is my code $this->db->from('sms'); $this->db->select('tags.id as tag_ids', 'tags.name as tag_names'); $this->db->join('sms', 'sms.id = tags_meta.sms_id', 'left'); $this->db->join('tags_meta', 'tags_meta.tag_id = tags.id', 'left'); $this->db->order_by('id', 'DESC'); $this->db->group_by('id'); //$sms = $this->db->get(); $pages = new Paginator(SETTING_SMS_PER_PAGE, 'page'); $pages->setTotal(count($this->db->count_all())); $data['pageLinks'] = $pages->pageLinks(); $data['smss'] = $this->db->get()->result();
Be Simple
![]()
What kind of help do you need? The error message says exactly what the problem is.
i don't know how to fix it. I don't have much knowledge in sql queries usage. So any guide on how to fix it?
Be Simple
![]()
You don't know enough SQL to fix a name conflict, but you're doing JOINs?
That query has more than one problem, it's not just the fatal error you're getting ... I can give you a cop-out answer that effectively hides the error message, but that won't be enough to fetch the correct result set. In fact, I probably would've done just that, but I see identifiers named "sms" and such ... Dealing with mobile messages is not homework given by a school teacher, nor something to just play with. I urge you to put an effort into learning basic SQL before continuing your work.
this is not mobile network stuffs. Its a kinda typo of www.freshsms.in www.spicysms.in which is why i have a table called sms. Right now you are not helping. I am here to seek for solution or an approach of solution to my problem.
Be Simple
![]()
Narf is right you should work on your SQL skills before you carry on.
Your error is very basic you can not use the same table in a JOIN and a FROM clause unless you use an ALIAS. change your join for PHP Code: $this->db->join('tags_meta', 'sms.id = tags_meta.sms_id', 'left'); |
Welcome Guest, Not a member yet? Register Sign In |