mysql

For each employee in employee table, find number of direct and indirect bosses in hierarchy

☆樱花仙子☆ 提交于 2021-02-08 06:09:24
问题 I am given an employee table which looks something like this: Queries to create sample input. CREATE TABLE employee( empId INTEGER, empName VARCHAR(20), mgrId INTEGER, salary DECIMAL(12,2) ); INSERT INTO employee VALUES (1, 'A', 2, 100), (2, 'B', 4, 150), (3, 'C', 4, 165), (4, 'D', 7, 200), (5, 'E', 6, 210), (6, 'F', 7, 250), (7, 'G', 7, 300), (8, 'H', 6, 170); Link to SQL Fiddle: http://sqlfiddle.com/#!9/cd4be8 This sample data results in this hierarchy. Each employee has a direct boss. Also

Multiple queries dependent on each other

孤街醉人 提交于 2021-02-08 06:08:13
问题 I have two queries both dependent on each other, i.e. if first query is not executed the second shouldn't be executed, and the other way around if second can't be executed the first shouldn't be executed. INSERT INTO `table` VALUES (1,2,3) UPDATE `otherTable` SET `val1`=1 WHERE `id`=$idOfInsert ON DUPLICATE KEY UPDATE is not the answer. I tried using mysqli::multi_query but as it turned out it executes the first even though the second can't be executed (it stops on error). How can I achieve

Multiple queries dependent on each other

一笑奈何 提交于 2021-02-08 06:06:18
问题 I have two queries both dependent on each other, i.e. if first query is not executed the second shouldn't be executed, and the other way around if second can't be executed the first shouldn't be executed. INSERT INTO `table` VALUES (1,2,3) UPDATE `otherTable` SET `val1`=1 WHERE `id`=$idOfInsert ON DUPLICATE KEY UPDATE is not the answer. I tried using mysqli::multi_query but as it turned out it executes the first even though the second can't be executed (it stops on error). How can I achieve

For each employee in employee table, find number of direct and indirect bosses in hierarchy

99封情书 提交于 2021-02-08 06:04:04
问题 I am given an employee table which looks something like this: Queries to create sample input. CREATE TABLE employee( empId INTEGER, empName VARCHAR(20), mgrId INTEGER, salary DECIMAL(12,2) ); INSERT INTO employee VALUES (1, 'A', 2, 100), (2, 'B', 4, 150), (3, 'C', 4, 165), (4, 'D', 7, 200), (5, 'E', 6, 210), (6, 'F', 7, 250), (7, 'G', 7, 300), (8, 'H', 6, 170); Link to SQL Fiddle: http://sqlfiddle.com/#!9/cd4be8 This sample data results in this hierarchy. Each employee has a direct boss. Also

How do I restrict access to user-defined functions in MySQL

纵然是瞬间 提交于 2021-02-08 05:47:19
问题 I am new to MySQL and I ran a Nessus scan on one my Servers and encountered a security finding which has a workaround to Restrict access to user-defined functions. Can someone help me please? Update The workaround is to Restrict access to create user-defined functions on the server 回答1: This should work. You can read more here http://dev.mysql.com/doc/refman/5.0/en/revoke.html REVOKE EXECUTE ON FUNCTION mydb.myfunc FROM 'someuser'@'somehost'; However, In my opinion it's better to grant

How do I restrict access to user-defined functions in MySQL

不羁岁月 提交于 2021-02-08 05:47:18
问题 I am new to MySQL and I ran a Nessus scan on one my Servers and encountered a security finding which has a workaround to Restrict access to user-defined functions. Can someone help me please? Update The workaround is to Restrict access to create user-defined functions on the server 回答1: This should work. You can read more here http://dev.mysql.com/doc/refman/5.0/en/revoke.html REVOKE EXECUTE ON FUNCTION mydb.myfunc FROM 'someuser'@'somehost'; However, In my opinion it's better to grant

Convert Oracle stored procedure using REF_CURSOR and package global variable to Postgresql or MySQL

我是研究僧i 提交于 2021-02-08 05:46:15
问题 This package uses two unique features of Oracle, REF_CURSOR and a package global variable. I would like to port the functionality from Oracle to Postgresql or MySQL. PACKAGE tox IS /*=======================*/ g_spool_key spool.key%TYPE := NULL; TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; /*=======================*/ PROCEDURE begin_spool; /*=======================*/ PROCEDURE into_spool ( in_txt IN spool.txt%TYPE ); /*=======================*/ PROCEDURE reset_spool; /*====================

Why does “M” appear in Clojure MySQL Query Results

梦想与她 提交于 2021-02-08 05:38:14
问题 I have a Clojure query that returns a row, and here is a partial printout of the returned row (map). ({:employer_percent 0.00M, ... :premium 621.44M, ...}) These two columns are decimal(5,2) and decimal(7,2) respectively in the mysql table. Why is there an 'M' suffix at the end of each of these values? Here is the code that forms and executes the query. (def db {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//system/app" :user "app-user" :password "pwrd"}) (defn get-recent

SQL Injection DROP TABLE not working

时间秒杀一切 提交于 2021-02-08 05:34:54
问题 I need to demonstrate SQL Inject using PHP/MySQL. I want to inject a DROP TABLE query in a login form but it never works. (TRUNCATE table works fine OTOH). After I input '; drop table users; # as field input; query turns out to be SELECT * FROM `users` WHERE `email` = ''; DROP TABLE users; #' AND `password` LIKE '3232'; But it never works using mysql_query() function. When I copy/paste this query in PHPmyAdmin directly, it works perfectly and table gets dropped. What can be the issue? 回答1:

What is the difference between package com.mysql.jdbc.PreparedStatement; and java.sql.PreparedStatement?

喜你入骨 提交于 2021-02-08 05:14:53
问题 I have connected JAVA application with MySql .When i wrote PreparedStatement ps = null ; then two option for import package was showing .The two suggested package was :com.mysql.jdbc.PreparedStatement; and java.sql.PreparedStatement .And , when i import com.mysql.jdbc.PreparedStatement package they said for casting as shown below . ps = (PreparedStatement) con.prepareStatement("INSERT INTO Authors(Name) VALUES(?)"); And when i used java.sql.PreparedStatement not need for casting in above