string Str="select class_role_rate from login where AccountNumber='" + txtIDText + "'; ";
sqlcommond com=new sqlcommond(Str,con);//con为你的SqlConnection对象
conopen();
SqlDataReader dr= comExecuteReader();
drRead();
string student=drGetString(0);
1找出座位数在100以上的航班(Aircraft, Noseats), 请列出其航班号(Flight, FlightNo), 飞机型号描述(Aircraft, Adescription), 起飞机场(Flight, FromAirport)及目的地机场(Flight,ToAirport)
答:select flightono,aircrafttype,fromairport,toairport from flight where AircraftType in (select aircrafttype from aircraft where noseats>100)
2从行程信息(Itinerary)中找出目的地机场(Flight,ToAirport)为COV的航班, 列出其航班号(Itinerary, FlightNo),起飞日期(Itinerary, FlightDate)
答:select flightno,flightdate from itinerary where flightno in (select flightno from Flight where toairport='COV')
3按照字母顺序排列, 找出可以起降ATP(Aircraft, AircraftType)型号飞机的机场(Airport)
答:select airport from airport where airport in (select fromairport from flight where fromairport='ATP') or airport in (select toairport from flight where toairport='ATP') order by airport asc
4列出2004年8月11日(11/8/2004 FlightDate)所有机票的票价(Ticket)
答:select price from tariff where faretype in (select faretype from itinerary where flightdate between'10/8/2004'and'12/8/2004')
5列出在凌晨1点(01:00 am Flight, DepTime)至凌晨5点30分(05:30 am Flight, DepTime)之间, 没有任何飞机起飞的机场(Airport)
答:select airport from airport where airport in (select fromairport from flight where left(right(convert(char,deptime,9),7),2))='am' and convert(char,deptime,8)>'01:00' and convert(char,deptime,8)<'05:30')
6列出所有买了至少两张机票(Ticket 每两张票180英镑,单位符号为 £ )的乘客(Passenger)
答:select name from passenger where pid in (select p from (select pid as p,count() as c from ticket group by pid having count() >1) as tic)
如果两个表有相同的列,那么就连接起来查询,没有的话 ---
创建视图,这个最方便
openConnection();
string sqlStr = "你的查询语句";
commCommandText = sqlStr;
commCommandType = CommandTypeText;
commConnection = conn;
SqlDataReader dr = commExecuteReader();
欢迎分享,转载请注明来源:品搜搜测评网