[eluser]pmhart[/eluser]
I am trying to do the following:
$this->db->join("tab as t", "t.id = " . $tab_id);
And I get an error that says:
Unknown column '25501' in 'on clause'
Given the $tab_id=25501, CI creates a query like this
JOIN `tab` as t ON `t`.`id` = `25501`
I need that number to not have backticks! I can do it as a valid query manually in mySQL, any suggestions?
[eluser]pmhart[/eluser]
anyone?
[eluser]kurucu[/eluser]
It doesn't look like a valid query to me, because I can't see how it would differ from a Where clause, but I'm no expert. I'd have thought you need to specify another table and column.
Anyway. The answer, as usual, appears to lie in the documentation, which says that you can just pass a SQL string into the select function, specifying the last parameter as FALSE to stop CI including backticks for you. This means you'd have to stop using active record for that particular query as the query is somewhat non-standard.
If you got it working in mysql, it would be worth pasting the code here if you still have problems later.
[eluser]pmhart[/eluser]
It works in SQL if I take out the backticks:
JOIN `tab` as t ON `t`.`id` = '25501'
[eluser]sophistry[/eluser]
that's not a job for JOIN. use WHERE.
[eluser]pmhart[/eluser]
Hmm, despite the "etiquette" of JOINs, it's valid to mySQL and does what I need.
I need to JOIN the "tab" table because it contains the submission ID. And tab attributes are sometimes referenced by a submission ID because the tab id was not added.
I can add tab to the FROM with a comma, but that query takes 8 seconds. Using a JOIN takes less than a split second.