-2
A
回答
1
这应该工作:
$this->db->orderby("date", "ASC"); //or desc
$query = $this->db->get('images'); //or $query = $this->db->get('note');
$result=$query->result_array();
print_r($result);
,或者如果你想使用UNION ALL
$this->db->query('SELECT * FROM (SELECT id, date FROM images UNION ALL SELECT id, date FROM note) result ORDER BY result.date');
注意,在联盟内每个SELECT语句必须具有相同的列数。这些列也必须具有相似的数据类型。另外,每个SELECT语句中的列必须与http://www.w3schools.com/sql/sql_union.asp的顺序相同。
0
你在哪张表中有日期栏?我假设你在图像表中有它。
$this->db->select('images.coulmn1, images.culmn2, images.date_col, note.col1, note.col2'); $this->db->from('images'); $this->db->join('note', 'note.key1 = images.key1); //key1 is key field to relate both table. $this->db->order_by("images.date_col", "desc"); $result = $this->db->get()->result_array();
希望这将有助于。
0
试试这个:
$this->db->select('*');
$this->db->from('images');
$this->db->join('note');
$this->db->orderby("date column name", "ASC");
$query = $this->db->get();
$result=$query->result_array();
print_r($result);
1
我想你想的交叉连接。 这里是你的codeigniter代码
$this->db->from("images ,note");
$this->db->select("images.*,note.*);
//make sure both dont have same column name other wise use this
//$this->db->select("images.column1,images.column2,note.column1);
$this->db->orderby("images.date", "DESC");
//you can add more orderby
//you can add where condition too
$result=$this->db->get()->result_array();
现在你会得到交叉产品。 希望它能帮助你。
相关问题
- 1. HTML - 两张桌子并排
- 2. wordpress按日期排序搜索结果
- 3. 数据库结构 - 两张桌子还是一张桌子?
- 4. 加入两个表按日期排序并显示结果
- 5. 参考一张桌子或另一张桌子的桌子排
- 6. 按日期排列的MySQL结果
- 7. Laravel查询生成器:如何按日期排序结果 - 先按未来日期的升序排序,然后按过去日期的降序排序。
- 8. 按两个顺序排序SQL结果
- 9. 用另一张桌子扩展桌子...排序
- 10. 按日期排序?
- 11. 按日期排序
- 12. 按日期排序
- 13. 按照评分排序评论结果的前两行,其余按日期排序?
- 14. 并排显示一张桌子,一个iframe和一张桌子
- 15. 的Mysql按日期排序和group by结果不同
- 16. Oracle按日期排序会给出不同的结果
- 17. 如何显示按日期排序的数据库结果$ row
- 18. Django按日期排序(日)
- 19. 两张桌子,两个独特的ID?
- 20. 按日期筛选结果,或者通过beetwen两个日期筛选结果
- 21. HTML - 两张桌子并排水平排列
- 22. 按日期对SPARQL结果进行排序
- 23. 我应该如何按日期排序结果?:Solr
- 24. 帮助在SQLite中按日期排序结果
- 25. MS Access SQL从不同的表中获取结果并按日期排序
- 26. 从两个表中排序SQL结果
- 27. 按日期排序数据?
- 28. 按日期分组排序
- 29. 排序包含按日期
- 30. SQL Server按日期排序
我试过,但它让我错误操作 '联盟''SELECT *排序规则的非法混用( (SELECT images.link,images.date从图像中) UNION ALL (SELECT note.name_slovak,note.date FROM note) )results ORDER BY date DESC' – PatrikD 2014-11-21 09:12:14