Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public function getInnerJoin(){
  2. return $this->find('columns: a.id, a.denominacion, (p.costo + (p.costo * p.ganancia / 100)) AS precio',
  3. 'join: a LEFT JOIN articulos.precio p on(a.id = p.articulo_id)',
  4. 'conditions: not exists (select 1 from articulos.precio p2 where p2.articulo_id = a.id and p2.fecha_at > p.fecha_at);');
  5. }
  6. public function buscar(){
  7. return $this->find_all_by_sql("SELECT a.id, a.denominacion, (p.costo + (p.costo * p.ganancia / 100)) AS precio
  8. FROM articulos.articulo a LEFT JOIN articulos.precio p on(a.id =p.articulo_id)
  9. WHERE not exists (select 1 from articulos.precio p2 where p2.articulo_id = a.id and p2.fecha_at > p.fecha_at);");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement