我在MySql Db中有一个名为newtbl的表,其中有2列作为外键引用,它们是m_id,p_id。我希望显示这些名称而不是这些m_id和p_id。
我写的查询在下面,但是有错误。
public void Main()
{
// TODO: Add your code here
string filename;//= Dts.Variables["User::filename"].Value.ToString();
filename = @"D:\VersionWithDummyData\finbalReviewTest.xlsm";
string S_Directory = @"D:\VersionWithDummyData\";
if (S_Directory.Substring(S_Directory.Length - 1, 1) != @"\")
{
S_Directory = S_Directory + @"\";
}
DirectoryInfo finfo = new DirectoryInfo(S_Directory);
if (filename.ToString().Substring(1, 2) != "~$")
{
try
{
xls.Application ExcelObj = new xls.Application();
ExcelObj.DisplayAlerts = true;
ExcelObj.Visible = true;
ExcelObj.DefaultFilePath = S_Directory;
xls.Workbook eBook = ExcelObj.Workbooks.Open(filename.ToString(), false, false,
Type.Missing, "", "", true, xls.XlPlatform.xlWindows, "",
false, false, 0, false, true, 0);
foreach (xls.WorkbookConnection wc in eBook.Connections)
{
if (wc.Type.ToString() == "xlConnectionTypeODBC")
{
wc.ODBCConnection.BackgroundQuery = false;
}
else
{
wc.OLEDBConnection.BackgroundQuery = false;
}
}
eBook.RefreshAll();
eBook.Save();
ExcelObj.Run("Module1",Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eBook.Save();
ExcelObj.Workbooks.Close();
ExcelObj.Quit();
}
catch (COMException e)
{
MessageBox.Show(filename.ToString() + " has an issue with error " + e.Message);
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
答案 0 :(得分:0)
您可以尝试使用as
select newtbl.*, pa.p_name, m.m_id as 'mmID'
from newtbl
left join matches m on newtbl.m_id = m.m_id
left join players pa on newtbl.p_id = pa.p_id
答案 1 :(得分:0)
下面是我的问题的答案。
select newtbl.u_id, pa.p_name from newtbl left join players pa on newtbl.p_id = pa.p_id