Welcome Guest, Not a member yet? Register   Sign In
Active Record Class Join question
#1

[eluser]Unknown[/eluser]
Hello I am having a little problem getting my head around the active record class. I have need make a simple SQL query. I have three tables tariff, state, and market. state and market have foreign keys inside the tariff table. Here is the SQL Query that works corectly on the data.
Code:
SELECT TARIFF.tariff_id, TARIFF.schedule, STATE.state, MARKET.name
FROM TARIFF,STATE, MARKET
WHERE TARIFF.state_id = STATE.state_id && MARKET.market_id = TARIFF.market_id

I get into trouble when I try to add the second and third tables into the mix. Can anyone help me out with the right way to do this. If I could see the example I think I could expand on it for the rest of my application.

Thank you in advance
#2

[eluser]xwero[/eluser]
Code:
$this->db->select('TARIFF.tariff_id, TARIFF.schedule, STATE.state, MARKET.name');
$this->db->from('TARIFF,STATE, MARKET');
$this->db->where('TARIFF.state_id = STATE.state_id && MARKET.market_id = TARIFF.market_id');
$result = $this->db->get();
#3

[eluser]Unknown[/eluser]
Xwero thank you so much. I thought I tried that I must have had a typo in my code when I tried it and that is why it didn't work. Thank you so much.




Theme © iAndrew 2016 - Forum software by © MyBB