Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Combines two or more `SELECT * from` together?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34807
    binboy
    Participant

    How can combines(merger) two or more “SELECT * from …” together by PHP and get from it output?(i use CodeIgniter)

    For example my database is as:

    http://oi55.tinypic.com/168shvn.jpg

    This is my try(Not work):


    $find1 = 'Boston'; // This is a input post $_POST[]
    $query = $this->db->query('SELECT name FROM array('Store_Information', 'Geography') WHERE name LIKE "%' . $find1 . '%"');

    $query_out = $query->row();
    echo $query_out->order;// This output should is this: "New Mexico"

    How is it?

    #89222
    SgtLegend
    Member

    See how this goes for you

    $query = $this->db->query('SELECT geo.order FROM Store_Information si LEFT JOIN Geography AS geo ON geo.id = si.id WHERE si.name LIKE "%' . $find1 . '%"');
    #89228
    binboy
    Participant

    How should echo output this query?

    #89262
    darkelda
    Member

    Use the UNION SQL Operator to concat your results
    http://dev.mysql.com/doc/refman/5.0/en/union.html

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.