from clrk as a
left join clrkmx as b on a.dwmc=b.dwmc and a.ggxh=b.ggxh and wzmc=wzmc//要有主外键关系,尽量写主外键的
left join ffcl as c on a.wzmc=c.wzmc and a.ggxh=c.ggxh
where ?.cgrq=传条件//抓狂,这个字段,三个表里都没有啊,还是没标出来,标出来的话,问号就是那个表
select sum(srsl) group by srfs
如果数据库是远程的话可以直接在工程中连接数据库public static class database
{
//数据库链接
static MySqlConnection Conn = null
//连接数据库
static void OpenConn()
{
if (Conn != null &&Conn.State == ConnectionState.Open)
{
Conn.Close()
}
if (Conn == null)
{
Conn = new MySqlConnection(你的数据库连接字符串)
}
if (Conn.State == ConnectionState.Closed)
{
Conn.Open()
}
}
//关闭数据库连接
static void CloseConn()
{
if (Conn != null)
{
Conn.Close()
}
}
//执行SQL语句
public static bool ExecSql(string strSql)
{
try
{
OpenConn()
MySqlCommand Cmd = new MySqlCommand(strSql, Conn)
Cmd.ExecuteNonQuery()
Cmd.Dispose()
return true
}
catch (Exception ex)
{
return false
}
finally
{
CloseConn()
}
}
//获取DataSet接口
public static DataSet GetDataSet(string strSql, string strDataSetName)
{
try
{
OpenConn()
DataSet dataSet = new DataSet()
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(strSql, Conn)
dataAdapter.Fill(dataSet, strDataSetName)
dataAdapter.Dispose()
return dataSet
}
catch(Exception ex)
{
return null
}
finally
{
CloseConn()
}
}
//获取MySqlDataReader接口
public static MySqlDataReader GetDataReader(string strSql)
{
try
{
OpenConn()
MySqlCommand Cmd = new MySqlCommand(strSql, Conn)
MySqlDataReader dataReader = Cmd.ExecuteReader()
return dataReader
}
catch (Exception ex)
{
return null
}
}
}
要去网上下一个MySql.Data.dll 然后倒入就可以使用上面的代码连接数据库了
SELECT tableAlias.fields FROM table AS Alias LEFT JOIN table1 AS Alias1 ON conditions LEFT JOIN table2 AS Alias2 ON conditions按照这个模式写出来就OK了
你的问题描述的不是很清楚,我也只能是给你一个模式了!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)