Hot answers tagged

2

The order of output expressions evaluation is not documented or specified. In general the evaluating order matches the text. Look. You assign @prev := u.plz and then try to compare these values - but they are already equal due to assigning. SELECT @prev as previous, -- @prev stores "old" value @prev := u.plz as ...


2

When you run the first two selects MySQL creates two X locks on supremum pseudo-record in tg_user_id because both ids (341292662 and 239302521) outside of the existing range. It looks like a bug. When you run inserts both of them try to get insert intention lock on the same record but they are blocked by previous locks. Edit Confirmed as bug: https://bugs....


1

use SUBSTRING_INDEX CREATE TABLE Table1 (`IP_address` varchar(15)) ; INSERT INTO Table1 (`IP_address`) VALUES ('1.2.3.4.5'), ('11.22.33.44.55'), ('5.6.7.8.9'), ('111.222.333.444') ; SELECT SUBSTRING_INDEX(`IP_address`,'.',3) FROM Table1; | SUBSTRING_INDEX(`IP_address`,'.',3) | | :---------------------------------- | | 1.2.3 ...


1

It appears you're having issues with apparmor, still loading the MySQL apparmor profile. According to this page, MariaDB's recommendation is to disable the mysqld profile like so: $ sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ $ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld # Verify $ sudo aa-status It seems that MariaDB ...


1

SIMPLY use user defined variales instead of variables. CREATE PROCEDURE `new_procedure` (IN tableA varchar(255)) BEGIN SET @sql = CONCAT(' select count(id) , orgid , (select id from org_subscription t where t.orgid=mainOrgID) into @count,@ParamOrgId ,@isPremium from ', tableA ); PREPARE stmt from @sql; EXECUTE stmt ; SELECT concat('my val is ', @...


1

Is there any way to collect somehow or write in another way query's which is repeated couple of times. I believe the term you're looking for is a "Data Abstraction Layer". This might take the form of some functions, or some classes with some methods on them, YMMV, but you basically build something that runs particular queries when they're called ...


1

Write 5 PHP subroutines, one for each query. Write 1 PHP subroutine and pass in (in the first case) "belongs_to", $belongs_to, then construct the query and run it. Write 5 SQL Stored Procedures. Write 1 SP. (But this gets rather messy.) Or... Don't worry about it.


1

Let's itemize the purposes/goals of a PRIMARY KEY: Uniquely identify each row of a table. This is a requirement for InnoDB. It provides the disk layout order for the data. This sometimes plays into performance issues. (Regular UUIDs are bad for performance because the "next" UUID is nowhere near the "last" UUID. That is the ...


1

Bignint is much faster than cvarchar or varbinary. at anbay time.. And so you can have 18446744073709551615 (unsigned) Rows. You would use uuids, when you enter data in different databases and try to unite them. but if you only need unique ids, use bigint.


1

If you have access to the Aria engine or another non-transactional engine, then yes. Very short proof of concept, tested on MariaDB 10.5.4: CREATE TABLE test_aria_engine ( a int, b varchar(1000) ) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 TABLE_CHECKSUM=1 COMMENT='test-aria_engine with transactional on 1' The transactional in Aria is ...


Only top voted, non community-wiki answers of a minimum length are eligible