SQL CASEµÄÓ÷¨£¬±ÈÏëÏóÖеÄÇ¿´ó
±íÈçÏÂ
Ò»ÌõÓï¾äÏÔʾËùÓдóÓÚ25ËêºÍϵÄÈË£¬ÒÔÉϵÄÈËÏÔ'´óÁä'
select case when age>25 then '´óÁä' else 'СÁä' end as ÄêÁä¼¶±ð,count(*) as ÈËÊý from infor group by case when age>25 then '´óÁä' else 'СÁä' end
Ïà¹ØÎĵµ£º
SQL Server×Ö·û´®´¦Àíº¯Êý´óÈ«
selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'Ô ......
SQL> select * from t1;
ID AGE
---------- ----------
1 20
2&nbs ......
--µ±Ç°Ê¹ÓõÄÊý¾Ý¿âÊÇ ÏµÍ³×Ô´øµÄ master
create database temp1
go --´Ë´¦²»¼ÓgoµÄ»°ÏÂÃæuse temp1 »á±¨´í£ºÕÒ²»µ½´æ´¢¹ý³Ì 'temp1'¡£
use temp1
set xact_abort on
begin tran
create table [order]( --orderÊǹؼü×Ö±ØÐëÓÃ[ ]£»
id int
)
create table fOrder(
id int
)
-- ÏÂÃæµÄ²Ù×÷Ö÷ÒªÊÇΪÁËʵÏÖfO ......
using System.Data.SqlClient;
using System.Data.OleDb;
private void tsmiImportTeacherInfo_Click(object sender, EventArgs e)
{
DataSet ds;
  ......