2

I have read all the posts regarding my issue in SO. But nothing fixed this.

Issue: When runs the mentioned query, below warning appears.

Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

Below is my query.

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))

purchase_items table

purchase_items table

EKBG
  • 243
  • 1
  • 8
  • 20
  • 1
    it's a warning and not an error. And it means exactly what it says, your query is a multi table join. Though each of the tables may have a primary key or a unique index, the complex query that phpmyadmin is displaying here cannot distinguish one row from another. There it's unable to let you delete or edit a row. – e4c5 Nov 10 '16 at 04:57
  • Thank you for this. But how can I overcome this, since I need the stock_id and item_id combination to unique and as well as the purchase_id. Adding more, I need not to add same item to the same stock. That is why I keep the combination as unique. – EKBG Nov 10 '16 at 04:58
  • use a different database client. – e4c5 Nov 10 '16 at 05:00
  • 1
    this is a problem in phpmyadmin what does that have to do with your system? – e4c5 Nov 10 '16 at 05:04

2 Answers2

1

I faced same problem when I use VIEW and looks like it's phpmyadmin just can't prove that there are columns in resulting query that unique by table design. In your case it's stock_id, but since there is multiple table join and stock_id is not present in other rows it is unable to deside what row shoild be affected on edit or delete. This warning could be disabled via config

$cfg['RowActionLinksWithoutUnique'] = true;

https://docs.phpmyadmin.net/en/latest/config.html#cfg_RowActionLinksWithoutUnique

This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available

Sumit
  • 2,242
  • 1
  • 24
  • 37
undermind
  • 36
  • 4
0

The Info button at the end of the Warning will take you to the phpMyAdmin configuration settings page where you will find:

$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).

This explains the Configuration setting. I ran into this issue when trying to use Multiple table joins where each of the tables didn't share a unique column although each of the join I used I used Unique Primary keys to establish the joins, but no matter how many different queries I wrote the only way to accomplish a Mass Edit is either in small join queries or add fields to your table to make it join with a unique primary key of another table. Hope that is helpful!

javadroid
  • 1,421
  • 2
  • 19
  • 43