在关系二表mysql中选择查询

时间:2015-11-06 10:57:29

标签: mysql sql

if (date("Y",strtotime($date)) == $i) $selected = ' selected="selected"';
        print('<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n");

您好,

假设父列0表示&#34;它是主要类别&#34;在类别表中,其他是其他类别的子类别。我想选择所有cat1和cat1子类别的子项。

1 个答案:

答案 0 :(得分:0)

检查此查询

select * from content_table where category IN (select id from category_table where parent IN 
(select id from category_table where cat_title = 'cat1'))