Query with data from 2 tables not editable when using mysql linked database

Libreoffice base 7.1.4.2/Ubuntu 21.4
I have and MYSQL database linked via ODBC connector.
mysql Ver 5.7.33, for FreeBSD12.2 (amd64)
and
mysql Ver 8.0.25, for FreeBSD12.2 (amd64)

I want simple form to display data from table “stocklist” filtered by keyword entered in a textfield above table control.
only way i managed to ahieve that is by adding secondary table, “stocksearch” and using it’s contents(always 1 row) in a query:

SELECT stocklist.part_no, stocklist.package, stocklist.bin, stocklist.line, stocklist.column1, stocklist.column2, stocklist.description, stocklist.order_no, stocklist.supplier, stocklist.number FROM stocklist, stocksearch WHERE stocklist.part_no LIKE CONCAT( ‘%’, stocksearch.term, ‘%’ ) OR stocklist.description LIKE CONCAT( ‘%’, stocksearch.term, ‘%’ ) ORDER BY stocklist.part_no ASC, stocklist.package ASC, stocklist.bin ASC, stocklist.line ASC, stocklist.column1 ASC

filtering works as a charm
but
As soon as I add second table to the query results become uneditable, even if do nothing with it.
mere existence of second table after FROM statement makes query results uneditable.
I tried virtually identical query in access and phpmyadmin and both give editable results.

Is such setup even possible in base? if so where do I begin?
and no , clicking trough several popups to get filers to work and expecting users(IT morons) to properly add wildcards to search phrase is not an acceptable solution, sorry.

After going trough some french tutorials(thanks google translate) I managed go get 2 table query give editable results on embedded tables.
Identical setup gives read only result with linked mysql tables.
At least with myODBC connector, direct connection driver for ubuntu 21.4 is utterly unstable.

Hello,

Using MySQL:

Screenshot at 2021-08-04 16-27-46

on Ubuntu 20.04.2 Mate with LO v7.1.5.2

Do not see stability problems with Native connector (it is a Maria DB connector). However did the test with ODBC connector.

Do not set query to Run SQL command directly. With that on you cannot edit. Remove the filter table (stocksearch) from the FROM statement and place an inline select in the WHERE such as:

WHERE `part_no` LIKE CONCAT('%',(Select `term` from `stocksearch`),'%')

With these changes I can edit records in a form or the query.

1 Like

Thank you :wink:
Instability is only in ubuntu 20.04 in libre 6.something(upgraded since)
and on ubuntu 21.4
libreoffice-mysql-connector 1:7.1.4-0ubuntu0.21.04.1 amd64
libreoffice-base 1:7.1.4-0ubuntu0.21.04.1 amd64

To reproduce create any form and link any table, then edit field twice.
by edit twice i mean edit, navigate away from control used, edit again.

on windows 10 and base 7.1.2.2 it works fine

Hi, the query needs all the primary keys of the tables used

thanks but that’s not it, even (pointless) query selecting all fields from both tables:
SELECT stocklist., stocksearch. FROM stocklist,stocksearch

produces not editable results.
there are * disappearing for some reason here.
I begin to think it’s only possible on native embedded tables, which su$$ as i need multi user capability.

Not only the primary keys are needed. Tables have also be linked … WHERE stocklist.part_no = … And the key of one table has to be foreignkey to the other.

Seems there is only needed one value in one row of stocksearch. So it is better to create a subquery like postet in the second answer.