I
I
Ilya Trusov2015-12-03 18:19:05
MySQL
Ilya Trusov, 2015-12-03 18:19:05

How to add data from another table?

Hello. I make such a request (based on codeigniter with its orm, but I think it will be clear)

$this->db->where('id_sender', $id_contact);
    $this->db->where('id_recipient', $id_user);
    $this->db->limit(5);
    $this->db->order_by('id', 'desc');
    $data = $this->db->get('messages');

Now I need to add data from the icons table, I do this:
$data = $this->db->query("SELECT
      a.*,
      b.*,
      FROM messages AS a LIMT 5

      LEFT JOIN icons AS b ON b.name = a.content

      WHERE (a.id_sender = $id_contact AND a.id_recipient = $id_user) ORDER BY a.id DESC");

But there's a mistake somewhere, I can't figure out where.
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Skorik, 2015-12-03
@artgrosvil

The word LIMIT is not correctly spelled and it seems to be at the very end of the request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question