我希望从联系人,contact_message和contact_reply数据中删除数据
联系表(1数据)
-id
-code
-ip
-date
列表
Array
(
[0] => Array
(
[id] => 5
[messageid] => 1
[message] => A new e-mail
[date] => 2017-01-18
)
)
contact_message表(1个数据)
-id
-messageid
-message
-date
列出contact_message数据
DELETE i,im FROM contact AS i
INNER JOIN contact_message AS im WHERE i.id=im.id and i.id=1
sql query
Çözümleme sırasında 3 hata bulundu.
Beklenmedik belirteç. (near "i" at position 7)
Beklenmedik belirteç. (near "," at position 9)
Beklenmedik belirteç. (near "im" at position 11)
SQL sorgusu:
DELETE i,im FROM contact AS i
INNER JOIN contact_message AS im WHERE i.id=im.id and i.id=1
MySQL çıktısı: Belgeler
#1054 - Unknown column 'i.id' in 'where clause'
结果(错误)
public static void FilterPivotItems(PivotField pf, List<string> pivotItemNames)
{
PivotItems pis = pf.ChildItems;
// Orientation != XlPivotFieldOrientation.xlHidden and we need to filter by at least one value (as Excel implies)
if (pf.Orientation != 0 && pivotItemNames.Count > 0)
{
int oldAutoSortOrder = 0;
if (pf.AutoSortOrder != (int)Constants.xlManual)
{
oldAutoSortOrder = pf.AutoSortOrder;
pf.AutoSort((int)Constants.xlManual, pf.Name);
}
int pivotItemsCount = pf.PivotItems().Count;
List<int> pivotItemsToHide = new List<int>();
for (int i = 1; i <= pivotItemsCount; i++)
{
PivotItem pi = pf.PivotItems(i);
// check if current pivot item needs to be hidden (if it exists in pivotItemNames)
var match = pivotItemNames.FirstOrDefault(stringToCheck => stringToCheck.Equals(pi.Value));
if (match == null)
{
// hide these pivot items later because we can hit exception "Unable to set the Visible property of the PivotItem class"
// (this happens because all pivot items get hidden and we need to have at least one visible)
pivotItemsToHide.Add(i);
}
else
{
TryFilterPivotItems(pi, true, true);
}
}
for (int i = 0; i < pivotItemsToHide.Count; i++)
{
PivotItem pi = pf.PivotItems(pivotItemsToHide[i]);
TryFilterPivotItems(pi, false, true);
}
if (oldAutoSortOrder != 0)
{
pf.AutoSort(oldAutoSortOrder, pf.Name);
}
PivotTable pt = pf.Parent as PivotTable;
if (pt != null)
{
pt.Update();
}
}
}
public static void TryFilterPivotItems(PivotItem currentPI, bool filterValue, bool deferLayoutUpdate = false)
{
try
{
PivotField pf = currentPI.Parent;
PivotTable pt = pf.Parent as PivotTable;
if (currentPI.Visible != filterValue)
{
if (deferLayoutUpdate == true && pt != null)
{
// just keep these three lines stick together, no if, no nothing (otherwise ManualUpdate will reset back to false)
pt.ManualUpdate = true;
currentPI.Visible = filterValue;
// this may be redundant since setting Visible property of pivot item, resets ManualUpdate to false
pt.ManualUpdate = false;
}
else
{
currentPI.Visible = filterValue;
}
}
}
catch (Exception ex)
{
}
}
public static void TryFilterPivotItems(PivotField pf, string itemValue, bool filterValue, bool deferLayoutUpdate = false)
{
try
{
PivotItem currentPI = pf.PivotItems(itemValue);
TryFilterPivotItems(currentPI, filterValue, deferLayoutUpdate);
}
catch (Exception ex)
{
}
}
你的解决方案是什么?
答案 0 :(得分:1)
我不确定为什么它不起作用,但你应该(尽管它是可选的)利用ON
而不是WHERE
- 它会减少行搜索,并且运行得更快更安全。 / p>
DELETE i, im FROM contact i
JOIN contact_message im ON i.id = im.id
WHERE i.id = 1