我已经在SO中阅读了有关我的问题的所有帖子。但没有解决这个问题。
问题: 运行上述查询时,会出现以下警告。
当前选择不包含唯一列。网格编辑,复选框,编辑,复制和删除功能不可用。
以下是我的查询。
SELECT ST.stock_code, S.supplier_name, I.item_name, P.avail_qty, SL.unit_price, P.expire_date
FROM purchase_items P
INNER JOIN stock ST ON P.stock_id = ST.stock_id
INNER JOIN suppliers S ON ST.sup_id = S.sup_id
INNER JOIN items I ON P.item_id = I.item_id
INNER JOIN sales SL ON P.item_id = SL.item_id
WHERE (P.expire_date > (NOW() + INTERVAL 1 MONTH))
答案 0 :(得分:1)
当我使用VIEW时遇到同样的问题,看起来它的phpmyadmin无法证明在结果查询中有一些列是由表设计独特的。在你的情况下它是stock_id,但由于有多个表连接而stock_id不存在于其他行中,因此无法确定在编辑或删除时哪些行受影响。 可以通过config
禁用此警告$cfg['RowActionLinksWithoutUnique'] = true
https://docs.phpmyadmin.net/en/latest/config.html#cfg_RowActionLinksWithoutUnique
答案 1 :(得分:0)
警告结束时的信息按钮将带您进入phpMyAdmin配置设置页面,您将在其中找到:
$cfg['RowActionLinksWithoutUnique']
Type: boolean
Default value: false
Defines whether to show row links (Edit, Copy, Delete) and checkboxes for
multiple row operations even when the selection does not have a unique key.
Using row actions in the absence of a unique key may result in different/more
rows being affected since there is no guaranteed way to select the exact
row(s).
这解释了配置设置。 我尝试使用多个表连接时遇到了这个问题,其中每个表都没有共享一个唯一列,尽管我使用的每个连接都使用了唯一主键来建立连接,但无论我写了多少不同的查询完成批量编辑的唯一方法是在小型连接查询中或向表中添加字段以使其与另一个表的唯一主键连接。 希望有帮助!