一个sql取出了很多数据,用了半天才解决

SELECT t1.*, t2.SortId FROM class_2 AS t1, class_3 AS t2 WHERE t2.SortId = t1.Typeid AND t1.SortId=’$id’

t2.SortId 有多少条取出多少条用这句话终于解决了

SELECT DISTINCT t1.*, t2.SortId FROM class_2 AS t1, class_3 AS t2 WHERE t2.SortId = t1.Typeid AND t1.SortId=’$id’

发表评论

电子邮件地址不会被公开。 必填项已用*标注