I have following tables structure.Need to select record from all tables those are recently added by added_date.
I am trying to fetch titlename, sourcename, description, addde_date from table1, table2, table3 those are recently added by added_date.
Title name and source name are store in Title and source table.
I have try union on these table but Table3 content the different columns.
table1
id titleid sourceid text_content added_date -------
1 15 20 XYzgff 10-10-2012:5:30pm
2 10 5 gghghggg 10-11-2012:5:30pm
table2
id titleid sourceid description added_date -------
1 6 8 fhjjjjjkk 11-04-2012:5:30pm
2 10 5 gghghggg 10-11-2012:5:30pm
table3
id url Title Description added_date -------------
1 ggggg fhhh llllll 31-04-2012:5:30pm
2 kkkkkk ttttt kkkkkk 10-11-2012:5:30pm
Title table:
titleid title_name
5 lgsfsgsf
6 lkklgyy
10 tyyiugj
15 lklklklkl
Source table:
sourceid source_name
5 jlkjljlj
8 ghhhhhhh
20 hhhhhhhf
6 llllllll
You should use
UNION. Try this (untested):Well I just realized you don’t have a SourceId or TitleId in your Table3. Not going to be able to get that information, but you could still do: