1. Select top 1是表示只显示满足条件的第一条记录,所以效率很高,编程经常用到,很实用。
if exists (select top 1 from ... where...)
//do 如果存在记录,也就是有返回结果就做什么事
print 'Exists Record !'
else
print 'Not Exists '
2.这个麻,
如果知道ID,那么最好直接用Select name from Tablexx where id=xx
如果用Join,就这么写select t1.name from Table1 t1
inner join table2 t2 on t1.id=t2.xx