SELECT @row := @row + 1 as row, t.id  FROM sgcorp_product t, (SELECT @row := 0) r  where t.id not in(select product_id from sgcorp_pic)


http://database.51cto.com/art/201011/235142.htm