天道酬勤,学无止境

mysql

How to remove the first word in an query

How can I remove the first word of an field in an MySQL query? I have tried to work with SUBSTRING_INDEX but no result. The field is varchar and can contain both letters and numbers Example: PWS 20110804 Pos. 04 should become 20110804 Pos. 04 PWS Pos. 04 should become Pos. 04 PWS AA.0804 Pos. 04 should become AA.0804 Pos. 04

2022-01-19 02:42:09    分类:问答    mysql

MySQLdb within python2.5 virtualenv

I have a Fedora 11 box with MySQL server. Fedora 11 uses python 2.6 internally and python 2.6 is automatically installed on the box. I have created a python virtual-env for version 2.5.5, so that I can run turbogears 1.x application. I have MySQLdb rpm installed on the box (and it works fine with python 2.6). When I import MySQLdb from within python version 2.6 it imports is successfully. When I import MySQLdb from within the python 2.5.5 virtual-env the import fails (because I have installed virtual-env with --no-site-packages). So, I have to install MySQLdb python as a local package (local

2022-01-19 02:39:41    分类:问答    python   mysql   virtualenv

Row number for query results grouped by a column

I have a table that has the following columns: id | fk_id | rcv_date There may be multiple records with a common fk_id, which represents a foreign key id in a related table. I need to create a query that will assign a row number to each record, grouped by fk_id, sorted by rcv_date. I originally began with the following query, which works quite well for sorting and assigning row numbers: SELECT @row:=@row +1 AS ordinality, c.fk_id, rcv_date FROM (SELECT @row:=0) r, mytable c ORDER BY rcv_date However -- the row count and sorting is done across the entire dataset. I need the counting to be

2022-01-19 02:38:18    分类:问答    mysql

Should id or timestamp be used to determine the creation order of rows within a database table? (given possibility of incorrectly set system clock)

A database table is used to store editing changes to a text document. The database table has four columns: {id, timestamp, user_id, text} A new row is added to the table each time a user edits the document. The new row has an auto-incremented id, and a timestamp matching the time the data was saved. To determine what editing changes a user made during a particular edit, the text from the row inserted in response to his or her edit is compared to the text in the previously inserted row. To determine which row is the previously inserted row, either the id column or the timestamp column could be

2022-01-19 02:37:00    分类:问答    mysql   database   schema

user add records to database PDO

I wish to let a user add records to an empty database table. As a matter of fact I have a database and an empty table which has to be filled using a form the first file handles the db connection (I use PDO)returns an empty page and a link named add which goes to a form <?php error_reporting(-1); ini_set('display_errors', 'On'); ?> <?php $servername = "localhost"; $username = "xxx"; $password = "xxx"; $dbname = "xxxx"; try { $dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE

2022-01-19 02:21:10    分类:问答    php   mysql   pdo

Detect missing values in a (auto-incremented) sequence

I have a 'Port' INT column, which it's supposed to range from 30000 to 50000. So, I have a Stored Procedure inserting values (Port is NOT NULL). So I have to choose 'manually' the value storing on that field. Problem is, altough I can insert incrementally (30000,30001,30002....) at a certain point some entries are deleted (it becames 30000, 30002, 30004.... ) so there are holes to be set. I need to place in my SP a way to fit those holes (on the example I have they are 30001,30003 ....). My problem is how to check within the SP, if a certain value is already 'ocuppied'. The I thought using

2022-01-19 01:59:28    分类:问答    mysql   loops

Select date from timestamp in SQLAlchemy

I'm using SQLAlchemy with python and i want to select date from column type timestamp, to do this query: SELECT DATE(`record_date`) FROM Users I made this code by sql alchemy but it will return the timestamp: session.query(Users.record_date).all() How can i do it?

2022-01-19 01:58:34    分类:问答    python   mysql   sqlalchemy

How to selectively dump all innodb tables in a mysql database?

I have a database called av2web, which contains 130 MyISAM tables and 20 innodb tables. I wanna take mysqldump of these 20 innodb tables, and export it to another database as MyISAM tables. Can you tell me a quicker way to achieve this? Thanks Pedro Alvarez Espinoza.

2022-01-19 01:54:57    分类:问答    mysql   innodb   mysqldump

Echo JS onclick fill function AJAX not working

I have a search bar with AJAX, MySQL, PHP, and JS. The search bar gives live search results in a div in a list and works in that respect. My problem is the live search results in the div list when clicked on do not fill the search bar's input. Nothing happens and the list just stays open unless I click out of it. I used to have it working in my old code where when you click on any result it fills the search bar's input, but ever since I rewrote the whole code I can't figure out why the onclick and fill functions aren't working now. How can I fix this code so that when a user clicks on one of

2022-01-19 01:51:13    分类:问答    javascript   php   mysql   ajax

Transient Failure handling in .net core 2.1 MVC for MySQL Database

services.AddDbContext<MyContext>(options => { options.UseSqlServer(mysqlConnection, sqlServerOptionsAction: sqlOptions => { sqlOptions.EnableRetryOnFailure( maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); }); }); I found this code snippet at: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-resilient-entity-framework-core-sql-connections My DB is MySQL 5.7 I changed the above code to : That means EnableRetryOnFailure is not available for MySQL DB. How do i set the retry, delay etc

2022-01-19 01:48:20    分类:问答    mysql   asp.net-core   .net-core   entity-framework-core