mysql

Set a repeating value to 0 while leaving the first value alone

*爱你&永不变心* 提交于 2021-02-08 07:47:40
问题 I am currently writing a report and noticed that I am getting repeated values. The issue is not that the values are repeating but that I am getting values that should be 0 after the first initial value. For example: My report is displaying the estimated shipping cost which might be $700 and since the order was broken up into 3 shipments, the report prints $700 3 times. This is not true because the estimated shipping should only be calculated one time. I am using iReport My question is: How do

NodeJS - how can get mysql result with executed query?

两盒软妹~` 提交于 2021-02-08 07:47:38
问题 I am new in NodeJS with mysql (npm install mysql). When I try to execute query like connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) { **here I want query which above executed** }); I want query in callback function which executed. How can I get it??. 回答1: var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) { console.log(c.sql) }); 回答2: connection.query(

NodeJS - how can get mysql result with executed query?

霸气de小男生 提交于 2021-02-08 07:47:03
问题 I am new in NodeJS with mysql (npm install mysql). When I try to execute query like connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) { **here I want query which above executed** }); I want query in callback function which executed. How can I get it??. 回答1: var c = connection.query("select ?? from users where id = ?",[["id","fname","lname"],req.body.userid],function (err, rows) { console.log(c.sql) }); 回答2: connection.query(

Passing JSON to PHP not working

六眼飞鱼酱① 提交于 2021-02-08 07:46:38
问题 I've been trying to get my python code to transfer SQL query data from client running python to web server running PHP, then input that data into a MySQL database. The below is the python test code simulating a single row: #!/usr/bin/python import requests import json url = 'http://192.168.240.182/insert_from_json.php' payload = {"device":"gabriel","data_type":"data","zone":1,"sample":5,"count":0,"time_stamp":"00:00"} headers = {'content-type': 'application/json'} response = requests.post(url

Populate form text field from database based on dropdown field selection

拜拜、爱过 提交于 2021-02-08 07:41:34
问题 I've dug through many posts but can't find a scenario quite like this on here... I have a PHP form that contains a dropdown selection containing option values from a MySQL database table. This part works fine. Here's where I need help... There is a textarea field that I need to populate with data from the same database table, but a different field. This table contains a 'name' and a corresponding set of 'text'. The dropdown shows the 'name' as the options. So what I need is when a selection

When connecting to multiple databases, do I need multiple SQLAlchemy Metadata, Base, or Session objects?

青春壹個敷衍的年華 提交于 2021-02-08 07:33:30
问题 I'm writing a SQLAlchemy app that needs to connect to a PostgreSQL database and a MySQL database. Basically I'm loading the data from an existing MySQL database, doing some transforms on it, and then saving it in PostgreSQL. I am managing the PostgreSQL schema using SQLAlchemy's declarative base . The MySQL database already exists, and I am accessing the schema via SQLAlchemy's reflection. Both have very different schemas. I know I need dedicated engines for each database, but I'm unclear on

MySQL query - join 3 tables together, group by one column and count for the other 2

試著忘記壹切 提交于 2021-02-08 07:33:30
问题 Here are examples of the 3 tables I'm working with. Teams +----+------+ | id | name | +----+------+ | 1 | abc | | 2 | def | | 3 | ghi | +----+------+ Members +----+-----------+----------+---------+ | id | firstname | lastname | team_id | +----+-----------+----------+---------+ | 1 | joe | smith | 1 | | 2 | jared | robinson | 1 | | 3 | sarah | cole | 3 | | 4 | jaci | meyers | 2 | +----+-----------+----------+---------+ Goals +----+-----------+ | id | member_id | +----+-----------+ | 1 | 3 | |

Metadata lock on MySQL 5.7, can't find locking process?

孤人 提交于 2021-02-08 07:32:29
问题 So I have a python server with a (currently asleep) connection to the MySQL database. I go to phpMyAdmin and just try to truncate the "tools" table, which is part of the "organize" database. But it doesn't work. Problem is, I can't seem to find which query is actually locking it. mysql> show full processlist; +-----+------+-----------+----------+---------+------+---------------------------------+------------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+------+

How to execute mysqldump command from the host machine to a mysql docker container

杀马特。学长 韩版系。学妹 提交于 2021-02-08 07:00:17
问题 I want to create mysql dumps for a database which is running in docker container. However I do not want to get into the container and execute the command but do it from the host machine. Is there a way to do it. I tried few things but probably I am wrong with the commands. docker exec -d mysql sh mysqldump -uroot -pSomePassword DBName > /dumps/MyNewDump.sql docker exec -d mysql sh $(mysqldump -uroot -pSomePassword DBName > /dumps/MyNewDump.sql) docker exec -d mysql mysqldump -uroot

how to get values for same column name from two different tables in SQL

吃可爱长大的小学妹 提交于 2021-02-08 06:59:24
问题 How to get values for same column name from two different tables in SQL? column name is emp_id loacated in these two tables: company,employee . 回答1: If you want data in seperate columns from two tables then try : SELECT c.emp_id, emp.emp_id FROM company c INNER JOIN employee emp on c.company_id = emp.company_id If you want to merge both columns data then use this : SELECT emp_id FROM company UNION SELECT emp_id FROM employee 回答2: Use this to get the results: company.emp_id, employee.emp_id