Welcome Guest, Not a member yet? Register   Sign In
Display recent user updates form two tables
#1

[eluser]ram reddy[/eluser]
Hi to all,


i have one problem , present working on link sharing project . here i have two tables 1. posted_links 2. shared_links

Posted_links table view => id, user_id, link_id, date_add

Shared_links table view => id, user_id, link_id, date_add

Aboue two tables collected in formation from 'link' table ; table view => id , link_id, url, title

My question is how to display recent user updates from posted_links and shared_links. Pls help to me
#2

[eluser]Mr. Pickle[/eluser]
I think using UNION in your query is the best if results are similar:

Code:
SELECT
    field
FROM
    table1

UNION

SELECT
    field
FROM
    table2
#3

[eluser]ram reddy[/eluser]
If i using union it shows an error
#4

[eluser]Mr. Pickle[/eluser]
And the error being....?
#5

[eluser]ram reddy[/eluser]
its working for me

$query1 = $this->db->get('Example_Table1');
$join1 = $this->db->last_query();
$query2 = $this->db->get('Example_Table2');
$join2 = $this->db->last_query();
$union_query = $this->db->query($join1.' UNION '.$join2.' ORDER BY column1,column2);




Theme © iAndrew 2016 - Forum software by © MyBB