sql

MySQL Select rows that from table01 that doesn't exist on table02 [duplicate]

廉价感情. 提交于 2021-02-17 06:55:26
问题 This question already has answers here : Find records from one table which don't exist in another (8 answers) Closed 10 months ago . I have two tables, table03 have 10 rows and table01 have 21 rows, now I want to get rows from table03 where they don't exist in table01, so far I wrote this query but it shows all rows of table03 even some rows doesn't exist on table01. SELECT T3.`DateAdded`, T3.`Query_name`, T3.`Fund`, T3.`Ticker` FROM `table_name03` T3 LEFT JOIN `table_name01` T1 ON T3.

mysql user variable assignement with count(*)

落爺英雄遲暮 提交于 2021-02-17 06:54:19
问题 I try to do query with a user variable, but I don't understand why, i can't update the variable in the query. I want to sum the grouped result for each day to do a chart. That really simple. SET @total := 0; SELECT "total Register", li.registerDate, @total := COUNT(*) + @total as registerNumber, @total FROM calendar c3 INNER JOIN ( SELECT c2.ide_calendar as ide_calendar, c2.name, DATE_FORMAT(i.date_creation, "%Y-%m-%d") as registerDate FROM calendrar c2 LEFT JOIN inscription i ON i.ide

Error (single-row subquery returns more than one row)

孤街浪徒 提交于 2021-02-17 06:54:06
问题 What is wrong with this query? select en.*, (select sf.red, sf.blue, sf.green, sf.yellow from data2 sf ) from data1 en; I have error ORA-01427: single-row subquery returns more than one row 01427. 00000 - "single-row subquery returns more than one row" 回答1: This is your query: select en.*, (select sf.red, sf.blue, sf.green, sf.yellow from data2 sf ) from data1 en; A subquery in the select used like this is called a scalar subquery . Such a subquery can be used where a scalar value (i.e.

insert in select in MySQL with JDBC

不想你离开。 提交于 2021-02-17 06:54:05
问题 I would like to have a value from a row inserted into an other row here is my code: static void addVipMonth(String name) throws SQLException { Connection conn = (Connection) DriverManager.getConnection(url, user, pass); PreparedStatement queryStatement = (PreparedStatement) conn.prepareStatement("INSERT INTO vips(memberId, gotten, expires) " + "VALUES (SELECT name FROM members WHERE id = ?, NOW(), DATEADD(month, 1, NOW()))"); //Put your query in the quotes queryStatement.setString(1, name);

SQL Server UTC string comparison not working

烈酒焚心 提交于 2021-02-17 06:53:06
问题 we have two SQL Servers. We have the following example SQL to recreate an issue we are facing. select * from ( select '2020-11-04 08:00:00' as start union all select '2020-11-04 08:00:00' as start ) a where cast(convert(date, a.start) as datetime) + cast(Cast(a.start AS time) as datetime) > '2020-11-04 08:00:00' when we run this query of the servers, one server returns two records and the other returns zero records. Both should should return zero records. We think there is some setting that

MySQL pivot row into dynamic number of columns

痴心易碎 提交于 2021-02-17 06:34:07
问题 Lets say I have three different MySQL tables: Table products : id | name 1 Product A 2 Product B Table partners : id | name 1 Partner A 2 Partner B Table sales : partners_id | products_id 1 2 2 5 1 5 1 3 1 4 1 5 2 2 2 4 2 3 1 1 I would like to get a table with partners in the rows and products as columns. So far I was able to get an output like this: name | name | COUNT( * ) Partner A Product A 1 Partner A Product B 1 Partner A Product C 1 Partner A Product D 1 Partner A Product E 2 Partner B

Filter by date using SQL

血红的双手。 提交于 2021-02-17 06:22:26
问题 I would like to know what do you think: I have to get all the connections I had to the system during a session. To automatize this process, I decided to use current_date%, which won't work because current_date is not a string, it's a function. So my question is if anyone can help me with the query to get the number of all the connections of the current day. Thanks in advance! My shitty code: SELECT COUNT(id) FROM user_connections WHERE connectiondate LIKE 'CURRENT_DATE%' 回答1: The best way

Statement cancelled due to timeout or client request

血红的双手。 提交于 2021-02-17 06:21:36
问题 I am trying to add data to my Google Cloud SQL database using Google App Script. My code was working fine last night when I finished but when I ran it this morning it is now giving me the error "statement cancelled due to timeout or client request", the error I am getting in the cloud console is "Got an error reading communication packets". Last night it was processing about 1,600 lines of data. I have played around with it and narrowed it down that the error will occur when there is more the

Statement cancelled due to timeout or client request

佐手、 提交于 2021-02-17 06:21:30
问题 I am trying to add data to my Google Cloud SQL database using Google App Script. My code was working fine last night when I finished but when I ran it this morning it is now giving me the error "statement cancelled due to timeout or client request", the error I am getting in the cloud console is "Got an error reading communication packets". Last night it was processing about 1,600 lines of data. I have played around with it and narrowed it down that the error will occur when there is more the

Create Table Error - Oracle SQL

萝らか妹 提交于 2021-02-17 06:19:04
问题 I need help with this it keeps giving the same error in Oracle SQL Developer. Error starting at line : 15 in command - CREATE TABLE B_BOOKING ( booking_number int NOT NULL PRIMARY KEY, date_booked date, performance_order int, base_pay int, band_number int, concert_number int, FOREIGN KEY REFERENCES B_CONCERT(concert_number) ) Error at Command Line : 21 Column : 34 Error report - SQL Error: ORA-00906: missing left parenthesis 00906. 00000 - "missing left parenthesis" *Cause: *Action: 回答1: You