EKBG
EKBG

Reputation: 253

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

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

Upvotes: 3

Views: 17497

Answers (2)

undermind
undermind

Reputation: 46

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

Upvotes: 2

Alexander Miller
Alexander Miller

Reputation: 1

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!

Upvotes: 0

Related Questions