mysql

mysql push notification

允我心安 提交于 2021-02-10 14:28:40
问题 Reading that MySQL doesn't have similar to SqlDependency . What is the best snippet to notify other users if a cell changed? Most of the current posts suggest pooling as recommended approach but can't find proper code to study for VB.NET Winform without using third party service such Nub. What I guess could work is to create a CRON job at http server to fetch if that cell(s) changed then store a flag in a secure file; then rather than keep checking MySQL database on interval; watch that flag

laravel like query is not working?

依然范特西╮ 提交于 2021-02-10 14:21:13
问题 This is my code : $lists = DB::table('connection_request as cr') ->leftJoin('users as u', function($join) { $join->on('u.id', '=', 'cr.sender_id')->orOn('u.id','=', 'cr.receiver_id'); }) ->select('cr.id as connection_id','cr.sender_id as sen_id','cr.receiver_id as rec_id','cr.approve_status','u.id','u.user_type','u.user_type_id',DB::raw("IF(u.avatar = '', 'uploads/avatar/default.jpg', u.avatar) as avatar"),'u.name','u.email') ->where(function($query) use ($user_id) { if(!empty($user_id)):

MySQL join in a JSON array

扶醉桌前 提交于 2021-02-10 14:14:52
问题 I have these rows in mysql table id categoryNameSp categoryNameEn 1 Comida Food 2 Fruta Fruit 3 Fruta Seca Dried fruit And then i have this row in another table pid path 1 ["1", "2", "3"] I want to return the path but instead of numbers i want to return categoryNameEn so the return will be: pid path 1 ["Food","Fruit", "Dried fruit"] 回答1: This would require to use the JSON_TABLE functionality as well as the JSON_ARRAYAGG aggregation function. Recreating your situation using the following DML

SQL left join two times

杀马特。学长 韩版系。学妹 提交于 2021-02-10 14:14:44
问题 The user table looks like this: user_id name surname 1 a aa 2 b bb 3 c cc The book's table looks like this: user_id book_name 1 book1 1 book2 1 book3 2 book1 The expenses table looks like this: user_id amount_spent date 1 10 2020-02-03 1 30 2020-02-02 1 10 2020-02-01 1 15 2020-01-31 1 13 2020-01-15 2 15 2020-02-01 3 20 2020-02-01 The result which I want: CountUsers amount_spent 2 65 Explanation: I want to count how many users have book1 and how much total they spend on a date between 2020-02

MySQL rejects column with ON DELETE SET NULL but not ON DELETE CASCADE

十年热恋 提交于 2021-02-10 13:26:23
问题 I have a simple MySQL database with some foreign keys on certain table columns. Some of the foreign key columns are set to ON DELETE SET NULL, and it seems to work fine. However, for one of the tables, I can't configure ON DELETE SET NULL - I can only configure ON DELETE CASCADE. The initial tables look like this: CREATE TABLE sessions( session_id int NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(50) NOT NULL, UNIQUE KEY uk_sessions(name)) COLLATE utf8_unicode_ci; CREATE TABLE blocks(

SET SQL_MODE=“NO_AUTO_VALUE_ON_ZERO”; gives an error

回眸只為那壹抹淺笑 提交于 2021-02-10 13:21:27
问题 I have problem with mysql database. I can't import a database from my friend. I need some help. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; ERROR: Unexpected beginning of statement. (near "phpMyAdmin" at position 0) Unrecognized statement type. (near "SQL" at position 11) #1064 - Something is wrong in your syntax obok 'phpMyAdmin SQL Dump SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"' w linii 1 回答1: There´s nothing wrong with you syntax, but probably with your file: most likely the

Convert dates into weeks

余生颓废 提交于 2021-02-10 12:50:13
问题 How to convert the continuous date into weeks , saturday should be the week ending Eample: 2/27/2015 3/6/2015 3/13/2015 3/20/2015 here I am giving more info on my requirement so that you can understand easily. I have a datetime field in my db lets say Date2. I need to group this date into weeks in mm/ dd/ yyyy. lets take an example my date2 start like 1/1/2015 to 20/1/2015 . 1/1/2015-3/1/2015 this range displayed as 3/1/2015, 4/1/2015-10/1/2015 ----------------------- 10/1/2015, 11/1/2015-17

left join multiplying values

爷,独闯天下 提交于 2021-02-10 12:31:41
问题 I have the following queries - SELECT COUNT(capture_id) as count_captures FROM captures WHERE user_id = 9 ...returns 5 SELECT COUNT(id) as count_items FROM items WHERE creator_user_id = 9 ...returns 22 I tried the following query - SELECT COUNT(capture_id) as count_captures, COUNT(items.id) as count_items FROM captures LEFT JOIN items ON captures.user_id = items.creator_user_id WHERE user_id = 9 ...but it returns two columns both with 110 as the value. I would want 5 in one column and 22 in

left join multiplying values

送分小仙女□ 提交于 2021-02-10 12:31:03
问题 I have the following queries - SELECT COUNT(capture_id) as count_captures FROM captures WHERE user_id = 9 ...returns 5 SELECT COUNT(id) as count_items FROM items WHERE creator_user_id = 9 ...returns 22 I tried the following query - SELECT COUNT(capture_id) as count_captures, COUNT(items.id) as count_items FROM captures LEFT JOIN items ON captures.user_id = items.creator_user_id WHERE user_id = 9 ...but it returns two columns both with 110 as the value. I would want 5 in one column and 22 in

SugarCRM - Database Failure - Row Size Too Large?

狂风中的少年 提交于 2021-02-10 12:28:08
问题 I've been building a custom module for sugarCRM and i'm running into some issue's, when installing the module i'm met with 'Database failure. Please refer to sugarcrm.log for details.' Upon checking the log file, i can find the error is this: "MySQL error 1118: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs 01/03/14" Whilst my module does have alot of fields, is there anyway i could get around