mysql-5.7

MySQL Query Algorithm - I am overwhelmed

江枫思渺然 提交于 2020-05-28 07:29:25
问题 I have 2 different tables. My goal is to find people who use the same ip address with different (name and surname). Table 2 - members id name surname 87 john but 88 john but 89 alex lopez 90 david beckham Table 1 - logs member_id ip_adress 87 1.1.1.1 88 1.1.1.1 89 2.2.2.2 90 2.2.2.2 The result I want to get ip_address members count 2.2.2.2 89,90 total (2 ) I have been trying for days, we could not solve. As a result, I need to get the above output. 回答1: Here's a SQLFiddle for your schema with

MySQL Query Algorithm - I am overwhelmed

梦想的初衷 提交于 2020-05-28 07:28:27
问题 I have 2 different tables. My goal is to find people who use the same ip address with different (name and surname). Table 2 - members id name surname 87 john but 88 john but 89 alex lopez 90 david beckham Table 1 - logs member_id ip_adress 87 1.1.1.1 88 1.1.1.1 89 2.2.2.2 90 2.2.2.2 The result I want to get ip_address members count 2.2.2.2 89,90 total (2 ) I have been trying for days, we could not solve. As a result, I need to get the above output. 回答1: Here's a SQLFiddle for your schema with

how to return alternative columns on join

不问归期 提交于 2020-05-17 06:58:25
问题 I have a table with a list of functionalities for my site. Say it has three columns: id_usr - url - landing_page 1 a.php a.html 2 b.php b.html 3 c.php c.html 4 d.php d.html Then I have a table where for each user i have those functionalities he can display: id_usr - func 1 1 1 3 My query selects those functionalities that the user is allowed to see and returns their url. So with the sample data it returns a.php, c.php And this is correct. The query is: SELECT titolo, descr1,descr2, url, url

how to return alternative columns on join

三世轮回 提交于 2020-05-17 06:58:05
问题 I have a table with a list of functionalities for my site. Say it has three columns: id_usr - url - landing_page 1 a.php a.html 2 b.php b.html 3 c.php c.html 4 d.php d.html Then I have a table where for each user i have those functionalities he can display: id_usr - func 1 1 1 3 My query selects those functionalities that the user is allowed to see and returns their url. So with the sample data it returns a.php, c.php And this is correct. The query is: SELECT titolo, descr1,descr2, url, url

case statement options splitted on two output columns

狂风中的少年 提交于 2020-05-17 06:14:05
问题 I have a table with a list of functionalities for my site. Say it has three columns: id_usr - url - landing_page 1 a.php a.html 2 b.php b.html 3 c.php c.html 4 d.php d.html Then I have a table where for each user i have those functionalities he can display: id_usr - func 1 1 1 3 This query (from this question of mine) SELECT f.id, CASE WHEN id_user IS NOT NULL THEN url ELSE landing_page END FROM funzioni f LEFT JOIN funz_abilitate fa ON fa.id_funzione = f.id AND fa.id_user = $id is returning

Why does COUNT() show only one row of table?

你离开我真会死。 提交于 2020-05-09 19:28:30
问题 I have the following table pet in the database menagerie : +--------+-------------+---------+------+------------+------------+ | name | owner | species | sex | birth | death | +--------+-------------+---------+------+------------+------------+ | Tommy | Salman Khan | Lebre | NULL | 1999-01-13 | 0000-00-00 | | Bowser | Diane | dog | m | 1981-08-31 | 1995-07-29 | +--------+-------------+---------+------+------------+------------+ Now If I run the following query: select owner, curdate() from

Create new columns for duplicate row values based on column ID duplicate in sql

心不动则不痛 提交于 2020-04-18 05:52:10
问题 I have a table with 2 columns, the first column is called ID and the second is called TRACKING . The ID column has duplicates, I want to to take all of those duplicates and consolidate them into one row where each value from TRACKING from the duplicate row is placed into a new column within the same row and I no longer have duplicates. I have tried a few suggested things where all of the values would be concatenated into one column but I want these TRACKING values for the duplicate ID s to be

How to replace a regex pattern in MySQL

▼魔方 西西 提交于 2020-04-07 10:46:33
问题 I have a table called myTable which has a column called col1 . This column contains data in this format: (1 or 2 digits)(hyphen)(8 digits). I want to replace all the data in this column and replace everything before hyphen with 4, so this is an example: -------------------------------- | old values | New Values | -------------------------------- | 1-654283568 => 4-654283568 | | 2-467862833 => 4-467862833 | | 8-478934293 => 4-478934293 | | 12-573789475 => 4-573789475 | | 16-574738575 => 4

MySQL 5.7.5+ get first row for the groups

本秂侑毒 提交于 2020-03-21 05:38:15
问题 I have a legacy application in which Group By has been used along with non aggregate columns to fetch the first row for each group. The query is as following: SELECT columnPrimaryKey, column1, column2, column3 FROM (SELECT columnPrimaryKey, column1, column2, column3 FROM testTable ORDER BY column2 ) AS tbl GROUP BY column3 Recently, the version was updated to 5.7.22 and now the above query is not returning expected results even after disabling the ONLY_FULL_GROUP_BY mode. Yes, I can rewrite

Error setting up MySQL: Table 'mysql.plugin' doesn't exist

时光毁灭记忆、已成空白 提交于 2020-02-24 03:42:21
问题 I have a MySQL 5.7 instance running without problems on Ubuntu 16, but when i try to install any other package or try to update existing ones through apt-get, i get the following error: # apt-get upgrade Setting up mysql-server-5.7 (5.7.20-0ubuntu0.16.04.1) ... Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. mysql_upgrade: [ERROR] 1146: Table 'mysql.plugin' doesn't exist mysql_upgrade failed with exit status 5 dpkg: error processing package